本文整理汇总了C#中SessionInfo.SendUnitData方法的典型用法代码示例。如果您正苦于以下问题:C# SessionInfo.SendUnitData方法的具体用法?C# SessionInfo.SendUnitData怎么用?C# SessionInfo.SendUnitData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionInfo
的用法示例。
在下文中一共展示了SessionInfo.SendUnitData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteLogixData
public static WriteDataServiceReply WriteLogixData(SessionInfo si, string tagAddress, ushort dataType, ushort elementCount, byte[] data, ushort structHandle = 0x0000)
#endif
{
WriteDataServiceRequest request = BuildLogixWriteDataRequest(tagAddress, dataType, elementCount, data, structHandle);
EncapsRRData rrData = new EncapsRRData();
rrData.CPF = new CommonPacket();
rrData.CPF.AddressItem = CommonPacketItem.GetConnectedAddressItem(si.ConnectionParameters.O2T_CID);
rrData.CPF.DataItem = CommonPacketItem.GetConnectedDataItem(request.Pack(), SequenceNumberGenerator.SequenceNumber);
rrData.Timeout = 2000;
EncapsReply reply = si.SendUnitData(rrData.CPF.AddressItem, rrData.CPF.DataItem);
if (reply == null)
return null;
if (reply.Status != 0)
{
return null;
}
return new WriteDataServiceReply(reply);
}
示例2: ReadLogixData
public static ReadDataServiceReply ReadLogixData(SessionInfo si, string tagAddress, ushort elementCount)
{
int requestSize = 0;
ReadDataServiceRequest request = BuildLogixReadDataRequest(tagAddress, elementCount, out requestSize);
EncapsRRData rrData = new EncapsRRData();
rrData.CPF = new CommonPacket();
rrData.CPF.AddressItem = CommonPacketItem.GetConnectedAddressItem(si.ConnectionParameters.O2T_CID);
rrData.CPF.DataItem = CommonPacketItem.GetConnectedDataItem(request.Pack(), SequenceNumberGenerator.SequenceNumber);
rrData.Timeout = 2000;
EncapsReply reply = si.SendUnitData(rrData.CPF.AddressItem, rrData.CPF.DataItem);
if (reply == null)
return null;
if (reply.Status != 0 && reply.Status != 0x06)
{
//si.LastSessionError = (int)reply.Status;
return null;
}
return new ReadDataServiceReply(reply);
}