public EnIPNetworkStatus ForwardOpen(EnIPAttribut Config, EnIPAttribut O2T, EnIPAttribut T2O, out ForwardClose_Packet ClosePacket, ForwardOpen_Config conf, bool WriteConfig = false) { ClosePacket = null; byte[] DataPath = GetForwardOpenPath(Config, O2T, T2O); if ((WriteConfig == true) && (Config != null)) // Add data segment { DataPath = EnIPPath.AddDataSegment(DataPath, Config.RawData); /* * byte[] FinaleFrame = new byte[DataPath.Length + 2 + Config.RawData.Length]; * Array.Copy(DataPath, FinaleFrame, DataPath.Length); * FinaleFrame[DataPath.Length] = 0x80; * FinaleFrame[DataPath.Length + 1] = (byte)(Config.RawData.Length / 2); // Certainly the lenght is always even !!! * Array.Copy(Config.RawData, 0, FinaleFrame, DataPath.Length + 2, Config.RawData.Length); * DataPath = FinaleFrame; */ } ForwardOpen_Packet FwPkt = new ForwardOpen_Packet(DataPath, conf); int Offset = 0; int Lenght = 0; byte[] packet; EnIPNetworkStatus Status; if (FwPkt.IsLargeForwardOpen) { Status = SendUCMM_RR_Packet(EnIPPath.GetPath(6, 1), CIPServiceCodes.LargeForwardOpen, FwPkt.toByteArray(), ref Offset, ref Lenght, out packet); } else { Status = SendUCMM_RR_Packet(EnIPPath.GetPath(6, 1), CIPServiceCodes.ForwardOpen, FwPkt.toByteArray(), ref Offset, ref Lenght, out packet); } if (Status == EnIPNetworkStatus.OnLine) { if (O2T != null) { O2T.O2T_ConnectionId = BitConverter.ToUInt32(packet, Offset); // badly made O2T.SequenceItem = new SequencedAddressItem(O2T.O2T_ConnectionId, 0, O2T.RawData); // ready to send } if (T2O != null) { T2O.Class1Enrolment(); T2O.T2O_ConnectionId = BitConverter.ToUInt32(packet, Offset + 4); } ClosePacket = new ForwardClose_Packet(FwPkt, T2O); } return(Status); }
public EnIPNetworkStatus ForwardClose(ForwardClose_Packet ClosePacket) { int Offset = 0; int Lenght = 0; byte[] packet; if (ClosePacket.T2O != null) { ClosePacket.T2O.Class1UnEnrolment(); } return(SendUCMM_RR_Packet(EnIPPath.GetPath(6, 1), CIPServiceCodes.ForwardClose, ClosePacket.toByteArray(), ref Offset, ref Lenght, out packet)); }
public EnIPNetworkStatus ForwardOpen(EnIPAttribut Config, EnIPAttribut O2T, EnIPAttribut T2O, out ForwardClose_Packet ClosePacket, uint CycleTime, bool P2P = false, bool WriteConfig = false) { ForwardOpen_Config conf = new ForwardOpen_Config(O2T, T2O, P2P, CycleTime); return(ForwardOpen(Config, O2T, T2O, out ClosePacket, conf, WriteConfig)); }