151 lines
5.2 KiB
C++
151 lines
5.2 KiB
C++
#include <iXcomTCP2.h>
|
|
#include <zudp/zudpICEI.h>
|
|
#include <common/L2Event.h>
|
|
#include <IceUtil/Thread.h>
|
|
#include <iDA/iDA.h>
|
|
#include <json/json.h>
|
|
#include <zudp/HandleMessage.h>
|
|
#include <base/FileStream.h>
|
|
using namespace iPlature;
|
|
using namespace baosight;
|
|
|
|
extern iDA::Connection con;
|
|
extern int gb_eventno;
|
|
extern string gb_name;
|
|
using namespace log4cplus;
|
|
using namespace iXcomTCP2;
|
|
using namespace IceUtil;
|
|
/**********************************************************************
|
|
* 概述: 构造函数,进行所需的初始化工作
|
|
* 函数名: zudpICEI
|
|
* 返回值:
|
|
* 参数列表: 参数类型 取值范围 描述
|
|
*
|
|
*ndle<UdpConnection> tHDL = new UdpConnection("10.25.27.66",8089,submsg);
|
|
IceUtil::ThreadControl tTC = tHDL->start();
|
|
版本历史
|
|
* 1.0 2010-06-18 echo_li 初次建立
|
|
*
|
|
**********************************************************************/
|
|
zudpICEI::zudpICEI()
|
|
{
|
|
LOG d("zudpIDLI::zudpICEI");
|
|
// ConfigMag configmag("CRGS");
|
|
// string ip=configmag.ReadProperty(gb_name,"server");
|
|
// string port=configmag.ReadProperty(gb_name,"port");
|
|
// string eventNo=configmag.ReadProperty(gb_name,"eventNo");
|
|
// string proxy=configmag.ReadProperty(gb_name,"proxy");
|
|
FileStream file;
|
|
string outstr = "";
|
|
file.read(file.getPath(file.getEnvPath()+"/config/udpconfig.json"),outstr);
|
|
Json::Value jvalue;
|
|
Json::Reader reader;
|
|
if(!reader.parse(outstr,jvalue))
|
|
{
|
|
d.Error()<<"can't read json:"<<outstr<<endl;
|
|
return ;
|
|
}
|
|
// d.Debug()<<jvalue[gb_name]["server"]<<endl;
|
|
// d.Debug()<<jvalue[gb_name]["port"]<<endl;
|
|
// d.Debug()<<jvalue[gb_name]["eventno"]<<endl;
|
|
// d.Debug()<<jvalue[gb_name]["proxy"]<<endl;
|
|
|
|
Handle<UdpConnection> sHDL = new UdpConnection(jvalue[gb_name]["server"].asString(),jvalue[gb_name]["port"].asInt() );
|
|
IceUtil::ThreadControl sTC = sHDL->start();
|
|
Handle<HandleMessage> tHDL = new HandleMessage(jvalue[gb_name]["eventno"].asInt(),jvalue[gb_name]["proxy"].asString());
|
|
IceUtil::ThreadControl tTC = tHDL->start();
|
|
|
|
}
|
|
|
|
/**********************************************************************
|
|
* 概述: 析构函数,进行必要的资源回收
|
|
* 函数名: ~zudpICEI
|
|
* 返回值:
|
|
* 参数列表: 参数类型 取值范围 描述
|
|
*
|
|
* 版本历史
|
|
* 1.0 2010-06-18 echo_li 初次建立
|
|
*
|
|
**********************************************************************/
|
|
zudpICEI::~zudpICEI(){
|
|
LOG d("zudpIDLI::~zudpICEI");
|
|
}
|
|
|
|
/**********************************************************************
|
|
* 概述: 向外提供的接口,用于接收简单的数据
|
|
* 函数名: SendDataShort
|
|
* 返回值: void
|
|
* 参数列表: 参数类型 取值范围 描述
|
|
* eventNo : [IN/OUT] ::Ice::Int 事件号
|
|
* seq : [IN/OUT] const ::Ice::ByteSeq & 传输的数据
|
|
* length : [IN/OUT] ::Ice::Int 数据的长度
|
|
* current : [IN/OUT] const Ice::Current &
|
|
*
|
|
* 版本历史
|
|
* 1.0 2010-06-18 echo_li 初次建立
|
|
*
|
|
**********************************************************************/
|
|
void
|
|
baosight::zudpICEI::SendDataShort(::Ice::Int eventNo,
|
|
const ::Ice::ByteSeq& seq,
|
|
::Ice::Int length,
|
|
const Ice::Current& current)
|
|
{
|
|
LOG log("zudpICEI::SendDataShort");
|
|
return;
|
|
}
|
|
|
|
/**********************************************************************
|
|
* 概述: 向外提供的接口,用于接收复杂的数据传输
|
|
* 函数名: SendDataLong
|
|
* 返回值: void
|
|
* 参数列表: 参数类型 取值范围 描述
|
|
* eventNo : [IN] ::Ice::Int 事件号
|
|
* seq : [IN] const ::Ice::ByteSeq & 数据流
|
|
* length : [IN] ::Ice::Int 数据长度
|
|
* sender : [IN] const ::std::string & 发送方
|
|
* reciver : [IN] const ::std::string & 接受方
|
|
* aditional : [IN] const ::std::string & 附加信息
|
|
* current : [IN] const Ice::Current &
|
|
*
|
|
* 版本历史
|
|
* 1.0 2010-06-18 echo_li 初次建立
|
|
*
|
|
**********************************************************************/
|
|
void
|
|
baosight::zudpICEI::SendDataLong(::Ice::Int eventNo,
|
|
const ::Ice::ByteSeq& seq,
|
|
::Ice::Int length,
|
|
const ::std::string& sender,
|
|
const ::std::string& reciver,
|
|
const ::std::string& aditional,
|
|
const Ice::Current& current)
|
|
{
|
|
LOG log("zudpICEI::SendDataLong");
|
|
log.Debug()<<"zudp SendDataLong"<<endl;
|
|
}
|
|
|
|
/**********************************************************************
|
|
* 概述: 用于定周期任务
|
|
* 函数名: TimeNotify
|
|
* 返回值: void
|
|
* 参数列表: 参数类型 取值范围 描述
|
|
* eventNo : [IN] ::Ice::Int 事件号
|
|
* seq : [IN] const ::Ice::ByteSeq & 数据流
|
|
* current : [IN] const Ice::Current &
|
|
*
|
|
* 版本历史
|
|
* 1.0 2010-06-18 echo_li 初次建立
|
|
*
|
|
**********************************************************************/
|
|
void
|
|
baosight::zudpICEI::TimeNotify(::Ice::Int eventNo,
|
|
const ::Ice::ByteSeq& seq,
|
|
const Ice::Current& current)
|
|
{
|
|
LOG log("zudpICEI::TimeNotify");
|
|
|
|
// commit changes on success
|
|
log.Debug()<<"zudp TimeNotify"<<endl;
|
|
}
|