public void ReplyS3F20(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg) { string newReplyMsg = GetMessageName(replyMsg.ToSml()); newReplyMsg += "< L[2]\r\n"; newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n>\r\n"; newReplyMsg += ">\r\n"; e.ReplyAsync(newReplyMsg.ToSecsMessage()); E87_HostCommand hcObj = new E87_HostCommand { Name = "CancelAllCarrier", MessageName = "S3F19", lpObj = null, carrierObj = null }; ThreadPool.QueueUserWorkItem(callback => { S3F19CancelAllCarrierEvent?.Invoke(this, hcObj); }); }
private void ReplyCancelBindService(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg) { // 0. < DATAID > // 1. < CARRIERACTION > // 2. < CARRIERID > // 3. < PTN > string newReplyMsg = GetMessageName(replyMsg.ToSml()); string carrierID = e.Message.SecsItem.Items[2].GetString(); Item PTNItem = e.Message.SecsItem.Items[3]; LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value; newReplyMsg += "< L[2]\r\n"; _carrierList.TryGetValue(carrierID, out SanwaCarrier carrierObj); if (lpObj == null) { //無對應Load Port newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else if (carrierObj == null) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_UNKNOWN_OBJECT_INSTANCE.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { _carrierList.Remove(carrierObj.ObjID); newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n>\r\n"; E87_HostCommand Obj = new E87_HostCommand { Name = "CancelBind", MessageName = "S3F17", lpObj = lpObj, carrierObj = carrierObj }; //S3F17CancelBindEvent?.Invoke(this, Obj); ThreadPool.QueueUserWorkItem(callback => { S3F17CancelBindEvent?.Invoke(this, Obj); }); } newReplyMsg += ">\r\n"; e.ReplyAsync(newReplyMsg.ToSecsMessage()); }
private void ReplyCancelCarrierNotificationService(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg) { // 0. < DATAID > // 1. < CARRIERACTION > // 2. < CARRIERID > // 3. < PTN > string newReplyMsg = GetMessageName(replyMsg.ToSml()); string carrierID = e.Message.SecsItem.Items[2].GetString(); newReplyMsg += "< L[2]\r\n"; _carrierList.TryGetValue(carrierID, out SanwaCarrier carrierObj); if (carrierObj == null) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_UNKNOWN_OBJECT_INSTANCE.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { _carrierList.Remove(carrierObj.ObjID); newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n>\r\n"; E87_HostCommand Obj = new E87_HostCommand { Name = "CancelCarrierNotification", MessageName = "S3F17", lpObj = null, carrierObj = carrierObj }; //S3F17CancelCarrierNotificationEvent?.Invoke(this, Obj); ThreadPool.QueueUserWorkItem(callback => { S3F17CancelCarrierNotificationEvent?.Invoke(this, Obj); }); } newReplyMsg += ">\r\n"; e.ReplyAsync(newReplyMsg.ToSecsMessage()); }
private void ReplyCarrierReCreate(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg) { // 0. < DATAID > // 1. < CARRIERACTION > // 2. < CARRIERID > // 3. < PTN > string newReplyMsg = GetMessageName(replyMsg.ToSml()); string carrierID = e.Message.SecsItem.Items[2].GetString(); Item PTNItem = e.Message.SecsItem.Items[3]; LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value; newReplyMsg += "< L[2]\r\n"; _carrierList.TryGetValue(carrierID, out SanwaCarrier carrierObj); if (lpObj == null) { //無對應Load Port newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } //else if (lpObj.IsReserved == E87_RS.RESERVED) //{ // newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; // newReplyMsg += "<L[2]\r\n"; // newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_ALREADY_IN_USE.ToString()); // newReplyMsg += "<A[0]>\r\n"; // newReplyMsg += ">\r\n"; //} else if (carrierObj == null) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_UNKNOWN_OBJECT_INSTANCE.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else if (lpObj.CurrentState != E87_LPTS.READY_TO_UNLOAD) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_COMMAND_NOT_VALID_FOR_CURRENT_STATE.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { Item CattrList = e.Message.SecsItem.Items[4]; ulong CheckCattrReturn = CheckCattrList(CattrList); if (CheckCattrReturn != SanwaACK.ERRCODE_NO_ERROR) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, CheckCattrReturn.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n>\r\n"; _carrierList.Remove(carrierID); SanwaCarrier newCarrierObj = new SanwaCarrier { ObjID = carrierID }; SetCarrierAttribute(CattrList, ref newCarrierObj); _carrierList.Add(newCarrierObj.ObjID, newCarrierObj); //ChangeReserviceState(lpObj, E87_RS.NOT_RESERVED); //LoadPortCarrierAssociated(lpObj, newCarrierObj, E87_ASSOCIATED.NOT_ASSOCIATION); ////等效於Bind //if (CattrList.Count > 0) //{ // ChangeReserviceState(lpObj, E87_RS.RESERVED); // LoadPortCarrierAssociated(lpObj, newCarrierObj, E87_ASSOCIATED.ASSOCIATION); //} E87_HostCommand Obj = new E87_HostCommand { Name = "CarrierReCreate", MessageName = "S3F17", lpObj = lpObj, carrierObj = newCarrierObj }; //S3F17CarrierReCreateEvent?.Invoke(this, Obj); ThreadPool.QueueUserWorkItem(callback => { S3F17CarrierReCreateEvent?.Invoke(this, Obj); }); } } newReplyMsg += ">\r\n"; e.ReplyAsync(newReplyMsg.ToSecsMessage()); }
private void ReplyCarrierNotificationService(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg) { // 0. < DATAID > // 1. < CARRIERACTION > // 2. < CARRIERID > // 3. < PTN > string newReplyMsg = GetMessageName(replyMsg.ToSml()); string carrierID = e.Message.SecsItem.Items[2].GetString(); newReplyMsg += "< L[2]\r\n"; _carrierList.TryGetValue(carrierID, out SanwaCarrier carrierObj); if (carrierObj != null) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_OBJECT_IDENTIFIER_IN_USE.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { Item CattrList = e.Message.SecsItem.Items[4]; ulong CheckCattrReturn = CheckCattrList(CattrList); if (CheckCattrReturn != SanwaACK.ERRCODE_NO_ERROR) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[2]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, CheckCattrReturn.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n>\r\n"; SanwaCarrier newCarrierObj = new SanwaCarrier { ObjID = carrierID }; SetCarrierAttribute(CattrList, ref newCarrierObj); _carrierList.Add(newCarrierObj.ObjID, newCarrierObj); E87_HostCommand Obj = new E87_HostCommand { Name = "CarrierNotification", MessageName = "S3F17", lpObj = null, carrierObj = newCarrierObj }; //S3F17CarrierNotificationEvent?.Invoke(this, Obj); ThreadPool.QueueUserWorkItem(callback => { S3F17CarrierNotificationEvent?.Invoke(this, Obj); }); } } newReplyMsg += ">\r\n"; e.ReplyAsync(newReplyMsg.ToSecsMessage()); }
public void ReplyChangeServiceStatus(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg, bool inService) { string newReplyMsg = GetMessageName(replyMsg.ToSml()); Item PTNItem = e.Message.SecsItem.Items[1]; Item ServiceStatusList; if (e.Message.SecsItem.Count == 3) //CHANGESERVICESTATUS { ServiceStatusList = e.Message.SecsItem.Items[2]; if (ServiceStatusList.Count > 0) { //0 :out of service //1 :In service Item PARAMVALItem = ServiceStatusList.Items[1]; switch (PARAMVALItem.Format) { case SecsFormat.ASCII: inService = PARAMVALItem.GetString() == "0" ? false : true; break; case SecsFormat.Binary: byte[] paramval = PARAMVALItem.GetValues <byte>(); inService = paramval[0] == 0x00 ? false : true; break; case SecsFormat.Boolean: inService = PARAMVALItem.GetValue <bool>(); break; case SecsFormat.F4: inService = PARAMVALItem.GetValue <float>() == 0.0f ? false : true; break; case SecsFormat.F8: inService = PARAMVALItem.GetValue <double>() == 0.0d ? false : true; break; case SecsFormat.I1: inService = PARAMVALItem.GetValue <byte>() == 0 ? false : true; break; case SecsFormat.I2: inService = PARAMVALItem.GetValue <short>() == 0 ? false : true; break; case SecsFormat.I4: inService = PARAMVALItem.GetValue <int>() == 0 ? false : true; break; case SecsFormat.I8: inService = PARAMVALItem.GetValue <long>() == 0 ? false : true; break; case SecsFormat.U1: inService = PARAMVALItem.GetValue <sbyte>() == 0 ? false : true; break; case SecsFormat.U2: inService = PARAMVALItem.GetValue <ushort>() == 0 ? false : true; break; case SecsFormat.U4: inService = PARAMVALItem.GetValue <uint>() == 0 ? false : true; break; case SecsFormat.U8: inService = PARAMVALItem.GetValue <ulong>() == 0 ? false : true; break; } } } LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value; newReplyMsg += "< L[2]\r\n"; if (lpObj == null) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n"; bool Return = true; if (inService) { Return = ChangeLoadPortState(lpObj, E87_LPTS.IN_SERVICE); if (Return) { E87_HostCommand hcObj = new E87_HostCommand { lpObj = lpObj, Name = "INSERVICE", MessageName = "S3F25" }; ThreadPool.QueueUserWorkItem(callback => { S3F25InServiceEvent?.Invoke(this, hcObj); }); } } else { Return = ChangeLoadPortState(lpObj, E87_LPTS.OUT_OF_SERVICE); if (Return) { E87_HostCommand hcObj = new E87_HostCommand { lpObj = lpObj, Name = "OUTOFSERVICE", MessageName = "S3F25" }; ThreadPool.QueueUserWorkItem(callback => { S3F25OutOfServiceEvent?.Invoke(this, hcObj); }); } } newReplyMsg += "<L[0]\r\n>\r\n"; } newReplyMsg += ">\r\n"; e.ReplyAsync(newReplyMsg.ToSecsMessage()); }
public void ReplyChangeReservePortStatus(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg, bool reserveAtPort) { string newReplyMsg = GetMessageName(replyMsg.ToSml()); Item PTNItem = e.Message.SecsItem.Items[1]; LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value; newReplyMsg += "< L[2]\r\n"; if (lpObj == null) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { bool Return = true; if (reserveAtPort) { Return = ChangeReserviceState(lpObj, E87_RS.RESERVED); } else { Return = ChangeReserviceState(lpObj, E87_RS.NOT_RESERVED); } if (Return) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n>\r\n"; if (reserveAtPort) { E87_HostCommand hcObj = new E87_HostCommand { lpObj = lpObj, Name = "RESERVEATPORT", MessageName = "S3F25" }; ThreadPool.QueueUserWorkItem(callback => { S3F25ReserveAtPortEvent?.Invoke(this, hcObj); }); } else { E87_HostCommand hcObj = new E87_HostCommand { lpObj = lpObj, Name = "CANCELRESERVEATPORT", MessageName = "S3F25" }; ThreadPool.QueueUserWorkItem(callback => { S3F25CancelReserveAtPortEvent?.Invoke(this, hcObj); }); } } else { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_ALREADY_IN_USE.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } } newReplyMsg += ">\r\n"; e.ReplyAsync(newReplyMsg.ToSecsMessage()); }
public void ReplyChangeAccess(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg, bool autoMode) { string newReplyMsg = GetMessageName(replyMsg.ToSml()); Item PTNItem = e.Message.SecsItem.Items[1]; Item ChangeAccessList; if (e.Message.SecsItem.Count == 3) //CHANGESERVICESTATUS { ChangeAccessList = e.Message.SecsItem.Items[2]; if (ChangeAccessList.Count > 0) { //0 :Manual //1 :Auto Item PARAMVALItem = ChangeAccessList.Items[1]; switch (PARAMVALItem.Format) { case SecsFormat.ASCII: autoMode = PARAMVALItem.GetString() == "0" ? false : true; break; case SecsFormat.Binary: byte[] paramval = PARAMVALItem.GetValues <byte>(); autoMode = paramval[0] == 0x00 ? false : true; break; case SecsFormat.Boolean: autoMode = PARAMVALItem.GetValue <bool>(); break; case SecsFormat.F4: autoMode = PARAMVALItem.GetValue <float>() == 0.0f ? false : true; break; case SecsFormat.F8: autoMode = PARAMVALItem.GetValue <double>() == 0.0d ? false : true; break; case SecsFormat.I1: autoMode = PARAMVALItem.GetValue <byte>() == 0 ? false : true; break; case SecsFormat.I2: autoMode = PARAMVALItem.GetValue <short>() == 0 ? false : true; break; case SecsFormat.I4: autoMode = PARAMVALItem.GetValue <int>() == 0 ? false : true; break; case SecsFormat.I8: autoMode = PARAMVALItem.GetValue <long>() == 0 ? false : true; break; case SecsFormat.U1: autoMode = PARAMVALItem.GetValue <sbyte>() == 0 ? false : true; break; case SecsFormat.U2: autoMode = PARAMVALItem.GetValue <ushort>() == 0 ? false : true; break; case SecsFormat.U4: autoMode = PARAMVALItem.GetValue <uint>() == 0 ? false : true; break; case SecsFormat.U8: autoMode = PARAMVALItem.GetValue <ulong>() == 0 ? false : true; break; } } } LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value; newReplyMsg += "< L[2]\r\n"; if (lpObj == null) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString()); newReplyMsg += "<A[0]>\r\n"; newReplyMsg += ">\r\n"; } else { E87RETURN_AM Return; if (autoMode) { Return = ChangeAccessMode(lpObj, E87_AM.AUTO); } else { Return = ChangeAccessMode(lpObj, E87_AM.MANUAL); } if (Return == E87RETURN_AM.SUCCESSFUL || Return == E87RETURN_AM.IN_ACCESS_MODE_ALREADY) { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n"; newReplyMsg += "<L[0]\r\n>\r\n"; if (Return == E87RETURN_AM.SUCCESSFUL) { if (autoMode) { E87_HostCommand hcObj = new E87_HostCommand { lpObj = lpObj, Name = "AUTOMODE", MessageName = "S3F25" }; S3F25AutoModeEvent?.Invoke(this, hcObj); } else { E87_HostCommand hcObj = new E87_HostCommand { lpObj = lpObj, Name = "MANUALMODE", MessageName = "S3F25" }; S3F25ManualModeEvent?.Invoke(this, hcObj); } } } else { newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n"; newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_OBJECT_IDENTIFIER_IN_USE.ToString()); newReplyMsg += "<A[0]>\r\n"; } } newReplyMsg += ">\r\n"; e.ReplyAsync(newReplyMsg.ToSecsMessage()); }
private void CheckLoadPortACK(bool GroupDefine, byte accessmode, LoadPort loadObj, ref SanwaLoadPortACK lpACKObj, ref bool allPTNSuccessful) { if (!CheckLoadPortACK(accessmode, loadObj, ref lpACKObj)) { allPTNSuccessful = false; } else { if (!GroupDefine) { if (accessmode == 0x01) { E87_HostCommand Obj = new E87_HostCommand { Name = "AUTOMODE", MessageName = "S3F27", lpObj = loadObj }; ThreadPool.QueueUserWorkItem(callback => { S3F27AutoModeEvent?.Invoke(this, Obj); }); } else { E87_HostCommand Obj = new E87_HostCommand { Name = "MANUALMODE", MessageName = "S3F27", lpObj = loadObj }; ThreadPool.QueueUserWorkItem(callback => { S3F27ManualModeEvent?.Invoke(this, Obj); }); } } else { if (accessmode == 0x01) { E87_HostCommand Obj = new E87_HostCommand { Name = "AUTOMODE", MessageName = "S3F21", lpObj = loadObj }; ThreadPool.QueueUserWorkItem(callback => { S3F21AutoModeEvent?.Invoke(this, Obj); }); } else { E87_HostCommand Obj = new E87_HostCommand { Name = "MANUALMODE", MessageName = "S3F21", lpObj = loadObj }; ThreadPool.QueueUserWorkItem(callback => { S3F21ManualModeEvent?.Invoke(this, Obj); }); } } } }