public bool ReadRequest(int Index, int Subindex) { bool flag = false; if (this._activate && this._lastService == PCP.LastService.Idle) { this._readDataValid = false; this._readDataError = false; byte[] data = new byte[10] { (byte)0, (byte)129, (byte)0, (byte)3, Convert.ToByte(this._invokeID & (int)byte.MaxValue), Convert.ToByte(this._commReference & (int)byte.MaxValue), PhoenixContact.PxC_Library.Util.Util.Int32ToByte(Index, 8), PhoenixContact.PxC_Library.Util.Util.Int32ToByte(Index, 0), Convert.ToByte(Subindex & (int)byte.MaxValue), (byte)0 }; if (flag = this._locMessage.SendRequest(data)) { this._lastService = PCP.LastService.ReadRequest; } } return(flag); }
public bool Disable() { if (this._activate) { this._activate = false; this._readDataValid = false; this._readDataError = false; this._readDataConfirmation = new byte[0]; this._writeDataDone = false; this._writeDataError = false; this._diagnostic.Disable(); } int num = this._locMessage.SendRequestOnly(new byte[8] { (byte)8, (byte)141, (byte)0, (byte)2, (byte)0, Convert.ToByte(this._commReference & (int)byte.MaxValue), (byte)0, (byte)0 }) ? 1 : 0; if (num != 0) { this._lastService = PCP.LastService.Abort; } this._ready = false; this._error = false; return(num != 0); }
public bool Enable() { bool flag = false; if (!this._activate && this._locMessage.ControllerId != 0) { this._activate = true; this._ready = false; this._error = false; this._readDataValid = false; this._readDataError = false; this._readDataConfirmation = new byte[0]; this._writeDataDone = false; this._writeDataError = false; this._diagnostic.Enable(); byte[] data = new byte[8] { (byte)0, (byte)139, (byte)0, (byte)2, (byte)0, Convert.ToByte(this._commReference & (int)byte.MaxValue), (byte)0, (byte)0 }; if (flag = this._locMessage.SendRequest(data)) { this._lastService = PCP.LastService.Initiate; } } return(flag); }
public bool WriteRequest(int Index, int Subindex, int ByteLength, byte[] Data) { bool flag = false; int num = 0; if (this._activate && this._lastService == PCP.LastService.Idle) { this._writeDataDone = false; this._writeDataError = false; if (ByteLength > 0 && Data != null) { num = ByteLength % 2 != 0 ? ByteLength + 1 : ByteLength; } int Integer = 3 + num / 2; byte[] data = new byte[4 + Integer * 2]; data[0] = (byte)0; data[1] = (byte)130; data[2] = PhoenixContact.PxC_Library.Util.Util.Int32ToByte(Integer, 8); data[3] = PhoenixContact.PxC_Library.Util.Util.Int32ToByte(Integer, 0); data[4] = Convert.ToByte(this._invokeID & (int)byte.MaxValue); data[5] = Convert.ToByte(this._commReference & (int)byte.MaxValue); data[6] = PhoenixContact.PxC_Library.Util.Util.Int32ToByte(Index, 8); data[7] = PhoenixContact.PxC_Library.Util.Util.Int32ToByte(Index, 0); data[8] = Convert.ToByte(Subindex & (int)byte.MaxValue); data[9] = Convert.ToByte(ByteLength & (int)byte.MaxValue); if (num <= Data.Length) { for (int index = 0; index < num; ++index) { data[10 + index] = Data[index]; } } if (num > Data.Length) { for (int index = 0; index < Data.Length; ++index) { data[10 + index] = Data[index]; } } if (flag = this._locMessage.SendRequest(data)) { this._lastService = PCP.LastService.WriteRequest; } } return(flag); }
private void _locMessage_OnException(Exception ExceptionData) { switch (this._lastService) { case PCP.LastService.ReadRequest: this._readDataError = true; this._readDataValid = false; break; case PCP.LastService.WriteRequest: this._writeDataError = true; this._writeDataDone = false; break; default: this._error = true; this._ready = false; break; } this._lastService = PCP.LastService.Idle; this._diagnostic.Throw((Enum)PCP_Diagnostic.MessageClientDiagnostic, new byte[0], ExceptionData); this._diagnostic.Quit(); }
private void _locMessage_OnConfirmationReceived(object Sender, byte[] Data) { if (!this._activate) { return; } if (PhoenixContact.PxC_Library.Util.Util.ByteToInt32(Data[0], Data[1]) == 32907) { if (PhoenixContact.PxC_Library.Util.Util.ByteToInt32(Data[6], Data[7]) == 0) { this._ready = true; this._error = false; this._lastService = PCP.LastService.Idle; if (this._hdEanbleReady == null) { return; } this._hdEanbleReady((object)this); } else { this._error = true; this._ready = false; this._diagnostic.Throw((Enum)PCP_Diagnostic.NegativeInitiateConfirmation, PhoenixContact.PxC_Library.Util.Util.GetByteArrayFromService(Data)); this._diagnostic.Quit(); this._lastService = PCP.LastService.Idle; } } else if (PhoenixContact.PxC_Library.Util.Util.ByteToInt32(Data[0], Data[1]) == 32898) { if (PhoenixContact.PxC_Library.Util.Util.ByteToInt32(Data[6], Data[7]) == 0) { this._writeDataDone = true; this._writeDataError = false; this._lastService = PCP.LastService.Idle; if (this._hdWriteConfirmationReceived == null) { return; } this._hdWriteConfirmationReceived((object)this); } else { this._writeDataDone = false; this._writeDataError = true; this._diagnostic.Throw((Enum)PCP_Diagnostic.NegativeWriteConfirmation, PhoenixContact.PxC_Library.Util.Util.GetByteArrayFromService(Data)); this._diagnostic.Quit(); this._lastService = PCP.LastService.Idle; } } else if (PhoenixContact.PxC_Library.Util.Util.ByteToInt32(Data[0], Data[1]) == 32897) { if (PhoenixContact.PxC_Library.Util.Util.ByteToInt32(Data[6], Data[7]) == 0) { this._readDataConfirmation = new byte[(int)Data[9]]; for (int index = 0; index < this._readDataConfirmation.Length; ++index) { this._readDataConfirmation[index] = Data[index + 10]; } this._readDataValid = true; this._readDataError = false; this._lastService = PCP.LastService.Idle; if (this._hdReadConfirmationReceived == null) { return; } this._hdReadConfirmationReceived((object)this, this._readDataConfirmation); } else { this._readDataValid = false; this._readDataError = true; this._diagnostic.Throw((Enum)PCP_Diagnostic.NegativeReadConfirmation, PhoenixContact.PxC_Library.Util.Util.GetByteArrayFromService(Data)); this._diagnostic.Quit(); this._lastService = PCP.LastService.Idle; } } else { this._lastService = PCP.LastService.Idle; this._error = true; this._ready = false; this._diagnostic.Throw((Enum)PCP_Diagnostic.UnexpectedService, PhoenixContact.PxC_Library.Util.Util.GetByteArrayFromService(Data)); this._diagnostic.Quit(); } }