public MultiServiceReply(EncapsReply reply) { EncapsRRData rrData = new EncapsRRData(); CommonPacket cpf = new CommonPacket(); int temp = 0; rrData.Expand(reply.EncapsData, 0, out temp); cpf = rrData.CPF; MessageRouterResponse response = new MessageRouterResponse(); response.Expand(cpf.DataItem.Data, 2, out temp); if (response.GeneralStatus == 0x1E) { IsPartial = true; } ReplyService = response.ReplyService; GenSTS = response.GeneralStatus; ServiceReplies = new List <ServiceReply>(); if (response.ResponseData != null) { Expand(response.ResponseData); } }
public ReadDataServiceReply(EncapsReply reply) { //First we have to get the data item... EncapsRRData rrData = new EncapsRRData(); CommonPacket cpf = new CommonPacket(); int temp = 0; rrData.Expand(reply.EncapsData, 0, out temp); cpf = rrData.CPF; //The data item contains the information in an MR_Response MR_Response response = new MR_Response(); response.Expand(cpf.DataItem.Data, 2, out temp); Service = response.ReplyService; Status = response.GeneralStatus; byte[] bbTemp = new byte[4]; Buffer.BlockCopy(BitConverter.GetBytes(Status), 0, bbTemp, 0, 2); if (Status == 0xFF) { if (response.AdditionalStatus_Size > 0) { Buffer.BlockCopy(response.AdditionalStatus, 0, bbTemp, 2, 2); } } ByteStatus = bbTemp; //Now check the response code... if (response.GeneralStatus != 0 && response.GeneralStatus != 0x06) { return; } if (response.ResponseData != null) { //Now we suck out the data type... DataType = BitConverter.ToUInt16(response.ResponseData, 0); byte[] tempB = new byte[response.ResponseData.Length - 2]; Buffer.BlockCopy(response.ResponseData, 2, tempB, 0, tempB.Length); Data = tempB; } else { DataType = 0x0000; } }
public ReadDataServiceReply(EncapsReply reply) { //First we have to get the data item... EncapsRRData rrData = new EncapsRRData(); CommonPacket cpf = new CommonPacket(); int temp = 0; rrData.Expand(reply.EncapsData, 0, out temp); cpf = rrData.CPF; //The data item contains the information in an MR_Response MR_Response response = new MR_Response(); response.Expand(cpf.DataItem.Data, 2, out temp); Service = response.ReplyService; Status = response.GeneralStatus; byte[] bbTemp = new byte[4]; Buffer.BlockCopy(BitConverter.GetBytes(Status), 0, bbTemp, 0, 2); if (Status == 0xFF) { if (response.AdditionalStatus_Size > 0) Buffer.BlockCopy(response.AdditionalStatus, 0, bbTemp, 2, 2); } ByteStatus = bbTemp; //Now check the response code... if (response.GeneralStatus != 0 && response.GeneralStatus != 0x06) return; if (response.ResponseData != null) { //Now we suck out the data type... DataType = BitConverter.ToUInt16(response.ResponseData, 0); byte[] tempB = new byte[response.ResponseData.Length - 2]; Buffer.BlockCopy(response.ResponseData, 2, tempB, 0, tempB.Length); Data = tempB; } else { DataType = 0x0000; } }
public WriteDataServiceReply(EncapsReply reply) { EncapsRRData rrData = new EncapsRRData(); CommonPacket cpf = new CommonPacket(); int temp = 0; rrData.Expand(reply.EncapsData, 0, out temp); cpf = rrData.CPF; MR_Response response = new MR_Response(); response.Expand(cpf.DataItem.Data, 2, out temp); if (response.GeneralStatus != 0) return; Service = response.ReplyService; Status = response.GeneralStatus; }
public WriteDataServiceReply(EncapsReply reply) { EncapsRRData rrData = new EncapsRRData(); CommonPacket cpf = new CommonPacket(); int temp = 0; rrData.Expand(reply.EncapsData, 0, out temp); cpf = rrData.CPF; MessageRouterResponse response = new MessageRouterResponse(); response.Expand(cpf.DataItem.Data, 2, out temp); if (response.GeneralStatus != 0) { return; } Service = response.ReplyService; Status = response.GeneralStatus; }
public MultiServiceReply(EncapsReply reply) { EncapsRRData rrData = new EncapsRRData(); CommonPacket cpf = new CommonPacket(); int temp = 0; rrData.Expand(reply.EncapsData, 0, out temp); cpf = rrData.CPF; MR_Response response = new MR_Response(); response.Expand(cpf.DataItem.Data, 2, out temp); if (response.GeneralStatus == 0x1E) IsPartial = true; ReplyService = response.ReplyService; GenSTS = response.GeneralStatus; ServiceReplies = new List<ServiceReply>(); if (response.ResponseData != null) Expand(response.ResponseData); }
private static TemplateInfo ReadStructAttributes(ushort structureId, LogixProcessor processor) { //First we have to get the template info... GetStructAttribsRequest attribsReq = new GetStructAttribsRequest(structureId); CommonPacketItem addressItem = CommonPacketItem.GetNullAddressItem(); UnconnectedSend ucmm = new UnconnectedSend(); ucmm.Priority_TimeTick = 0x07; ucmm.Timeout_Ticks = 0x9B; ucmm.RoutePath = processor.Path; ucmm.MessageRequest = new MR_Request(); ucmm.MessageRequest.Request_Path = new byte[] { 0x20, 0x6C, 0x25, 0x00, (byte)((structureId & 0x00FF)), (byte)((structureId & 0xFF00) >> 8) }; ucmm.MessageRequest.Service = 0x03; ucmm.MessageRequest.Request_Data = new byte[] { 0x04, 0x00, 0x04, 0x00, 0x03, 0x00, 0x02, 0x00, 0x01, 0x00 }; ucmm.RequestPath = CommonPaths.ConnectionManager; CommonPacketItem dataItem = CommonPacketItem.GetUnconnectedDataItem(ucmm.Pack()); EncapsReply reply = processor.SessionInfo.SendRRData(addressItem, dataItem); if (reply.Status != 0x00) return null; //We have to get the data out... EncapsRRData rrData = new EncapsRRData(); CommonPacket cpf = new CommonPacket(); int temp = 0; rrData.Expand(reply.EncapsData, 0, out temp); cpf = rrData.CPF; byte[] replyData = new byte[28]; Buffer.BlockCopy(cpf.DataItem.Data, 4, replyData, 0, 28); GetStructAttribsReply structAttribs = new GetStructAttribsReply(replyData); //Great... now we can request the structure template and be able to read it! ucmm.MessageRequest.Service = 0x4C; //We can only read about 480 bytes at a time, so we may have to break it up... uint bytesRemaining = (structAttribs.TemplateSize - 5) * 4; uint offset = 0; List<byte> structInfoBytes = new List<byte>(); while (bytesRemaining > 0) { ushort bytesToRead; if (bytesRemaining < 480) { bytesToRead = (ushort)bytesRemaining; bytesRemaining = 0; } else { bytesToRead = 480; bytesRemaining -= 480; } byte[] tempB = new byte[6]; Buffer.BlockCopy(BitConverter.GetBytes(offset), 0, tempB, 0, 4); Buffer.BlockCopy(BitConverter.GetBytes(bytesToRead), 0, tempB, 4, 2); ucmm.MessageRequest.Request_Data = tempB; dataItem = CommonPacketItem.GetUnconnectedDataItem(ucmm.Pack()); reply = processor.SessionInfo.SendRRData(addressItem, dataItem); if (reply.Status != 0x00) continue; rrData.Expand(reply.EncapsData, 0, out temp); cpf = rrData.CPF; //get the data out... tempB = new byte[cpf.DataItem.Data.Length - 4]; Buffer.BlockCopy(cpf.DataItem.Data, 4, tempB, 0, cpf.DataItem.Data.Length - 4); structInfoBytes.AddRange(tempB); offset += bytesToRead; } //Now we have all the data!!!! return new TemplateInfo(structInfoBytes.ToArray(), structAttribs); }