Giter Site home page Giter Site logo

hsmscpp's Introduction

GemDemo

Demo for SECS HSMS communication

Example

通讯库支持SECS-I与HSMS两种通讯方式。区别在初始化时,使用不同的参数类型。 其它的函数是一样的。

创建通讯库对象

GemPtr pGem = CGem::GetInstancePtr();

初始化连接

Secs-I

SecsSet sset;
sset.sComName = "COM1";
sset.uBaudrate = 9600;
sset.uDevID = 1;
sset.mode = CSECS_EQUIP;

pGem->InitLink(sset);

Secs-II (HSMS)

HsmsSet set;
set.uLocalPort = 5000;
set.mode = CHSMS_PASSIVE;
set.uDevID = 1;

pGem->InitLink(set);

设置消息接收处理

pGem->SetSecsRecvFun([this](const SecsMessage& msg) {
	return handleMessage(msg);
	});

启动连接

pGem->Connect();

发送消息

ItemPtr iSend = Item::L();
iSend->Append(Item::B(6));
iSend->Append(Item::U2(10));
iSend->Append(Item::A("Fire Alarm"));

SecsMessage smsg{ 5, 1, iSend };
mid = pGem->Send(smsg);

回应消息

ItemPtr item = Item::L();
item->Append(Item::A("DemoEquip"));
item->Append(Item::A("Rev 1.0"));

SecsMessage rmsg{1, 2, item, msg.MID};
m_pGem->Reply(rmsg);

联系方式

[email protected]
QQ/WeChat: 15782317

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.