必须最少引用头文件

This commit is contained in:
Stone 2016-10-09 17:09:27 +00:00
parent 8f0f21b30f
commit f11a652f3f
4 changed files with 17 additions and 12 deletions

View File

@ -11,6 +11,8 @@
#include "TokenNet\TokenController.h"
#include "Device\RTC.h"
AP0801* AP0801::Current = nullptr;
AP0801::AP0801()
@ -168,7 +170,7 @@ void AP0801::InitClient()
// 创建客户端
auto client = new TokenClient();
client->Cfg = tk;
// 需要使用本地连接
//client->UseLocal();
@ -286,13 +288,13 @@ void AP0801::OpenClient(ISocketHost& host)
// {
// debug_printf("4");
// auto ctrl = AddControl(*HostAP, uri, tk->Port);
//
//
// // 如果没有主机,这里打开令牌客户端,为组网做准备
// if(!Host)
// if(!Host)
// Client->Open();
// else
// else
// Client->AttachControls();
//
//
// // 假如来迟了,客户端已经打开,那么自己挂载事件
// if(Client->Opened && Client->Master)
// {

View File

@ -7,7 +7,6 @@
#include "TokenNet\TokenClient.h"
#include "Message\ProxyFactory.h"
#include "App\Alarm.h"
#include "Device\RTC.h"
// 阿波罗0801/0802
class AP0801

View File

@ -14,7 +14,7 @@ error code
ProxyFactory::ProxyFactory():Proxys(String::Compare)
{
debug_printf("创建 ProxyFac\r\n");
Client = nullptr;
Client = nullptr;
}
bool ProxyFactory::Open(TokenClient* client)
@ -32,6 +32,7 @@ bool ProxyFactory::Open(TokenClient* client)
Client->Register("Proxy/Read", &ProxyFactory::Read, this);
Client->Register("Proxy/QueryPorts",&ProxyFactory::QueryPorts, this);
debug_printf("\r\n");
return true;
}
@ -244,23 +245,27 @@ bool ProxyFactory::QueryPorts(const Pair& args, Stream& result)
bool ProxyFactory::Upload(Proxy& port, Buffer& data)
{
if (!Client)return false;
MemoryStream ms;
BinaryPair bp(ms);
bp.Set("Port", port.Name);
bp.Set("Data", data);
Client->Invoke("Proxy/Upload", Buffer(ms.GetBuffer(),ms.Position()));
return true;
}
bool ProxyFactory::UpOpen(Proxy& port)
{
if (!Client)return false;
MemoryStream ms;
BinaryPair bp(ms);
bp.Set("Port", port.Name);
bp.Set("Open", (byte)0x01);
Client->Invoke("Proxy/Open", Buffer(ms.GetBuffer(), ms.Position()));
return true;
}

View File

@ -2,7 +2,6 @@
#define __ProxyFactory_H__
#include "Sys.h"
#include "TokenNet\TokenMessage.h"
#include "Message\Pair.h"
#include "TokenNet\TokenClient.h"
#include "Device\Proxy.h"
@ -11,12 +10,12 @@
class ProxyFactory
{
public:
Dictionary<cstring, Proxy*> Proxys;
TokenClient* Client;
ProxyFactory();
// 工程打开
bool Open(TokenClient* client);
// 端口注册
@ -32,7 +31,7 @@ public:
bool SetConfig(const Pair& args, Stream& result);
// 获取设备列表
bool QueryPorts(const Pair& args, Stream& result);
// XXX7自动bool Proxy/SetAuto(bool auto, Byte[] boot)。 // 设备上电后自动发送,可能需要引导数据 => 合并到2
// 8查询状态Byte[] Proxy/Query(String port, String key)。 // 支持查询是否已打开、已缓存数据量等。