public Telegram(double _Delay, int _Sender, int _Receiver, TelegramType _Type)
 {
     this.Sender       = _Sender;
     this.Receiver     = _Receiver;
     this.DispatchTime = _Delay;
     this.MsgType      = _Type;
 }
Esempio n. 2
0
    public Telegram(int s, int r, TelegramType tt, bool ir, Vector3? l, float dt)
	{
		DispatchTime = dt;
		Sender = s;
		Receiver = r;
		TelegramType = tt;
        IsResponse = ir;
		Location = l;
	}
Esempio n. 3
0
	public static void DispatchMessage(int sender, int receiver, TelegramType telegramType, bool isResponse = false,  Vector3? location = null, float delay = 0.0f)
	{
		Telegram telegram = new Telegram (sender, receiver, telegramType, isResponse, location, delay);

		if (delay <= 0.0f) 
		{
			CognitiveAgent rAgent = AgentManager.Instance.GetAgent(receiver).CognitiveAgent;
			SendMessage(rAgent, telegram);
		}
		else
		{
			telegram.DispatchTime = Time.time + delay;
			telegramQueue.Add(telegram);
		}
	}
        public void DispatchMessage(double _Delay, int _Sender, int _Receiver, TelegramType _Type)
        {
            BaseGameEntity Sender = EntityManager.Instance.GetEntity(_Sender);

            Telegram t = new Telegram(_Delay, _Sender, _Receiver, _Type);

            if (_Delay <= 0.00)
            {
                BaseGameEntity Receiver = EntityManager.Instance.GetEntity(_Receiver);
                Discharge(Receiver, t);
            }
            else
            {
                double currentTime = DateTime.Now.Ticks;
                t.DispatchTime = currentTime + _Delay;
                delayedMessages.Add(t);
            }
        }
Esempio n. 5
0
        //check if the DB can be written again or not
        private bool CheckFlagDB(TelegramType teltype)
        {
            bool bOK = false,
            //for CTS_Lift_Drop / New Target
                 bDrop   = false,
                 bLift   = false,
                 bTarget = false;

            switch (teltype)
            {
            case TelegramType.Lock_Request:
                bOK = _client._plcConnection.ReadBoolean("DB51.DBX 1.0");
                //in case the DB was blocked, sleep and try again
                if (bOK == true)
                {
                    Thread.Sleep(_iTimer);
                    bOK = _client._plcConnection.ReadBoolean("DB51.DBX 1.0");
                }
                break;

            case TelegramType.CTS_Lift_Drop:
                bLift   = _client._plcConnection.ReadBoolean("DB51.DBX 1.1");
                bDrop   = _client._plcConnection.ReadBoolean("DB51.DBX 1.2");
                bTarget = _client._plcConnection.ReadBoolean("DB51.DBX 1.3");

                bOK = bLift || bDrop || bTarget;
                //in case the DB was blocked, sleep and try again
                if (bOK == true)
                {
                    Thread.Sleep(_iTimer);
                    bLift   = _client._plcConnection.ReadBoolean("DB51.DBX 1.1");
                    bDrop   = _client._plcConnection.ReadBoolean("DB51.DBX 1.2");
                    bTarget = _client._plcConnection.ReadBoolean("DB51.DBX 1.3");

                    bOK = bLift || bDrop || bTarget;
                }
                break;

            case TelegramType.New_Target:
                bLift   = _client._plcConnection.ReadBoolean("DB51.DBX 1.1");
                bDrop   = _client._plcConnection.ReadBoolean("DB51.DBX 1.2");
                bTarget = _client._plcConnection.ReadBoolean("DB51.DBX 1.3");

                bOK = bTarget || bLift || bDrop;
                //in case the DB was blocked, sleep and try again
                if (bOK == true)
                {
                    Thread.Sleep(_iTimer);
                    bLift   = _client._plcConnection.ReadBoolean("DB51.DBX 1.1");
                    bDrop   = _client._plcConnection.ReadBoolean("DB51.DBX 1.2");
                    bTarget = _client._plcConnection.ReadBoolean("DB51.DBX 1.3");

                    bOK = bTarget || bLift || bDrop;
                }
                break;

            case TelegramType.New_Slab_Scarfing:
                bOK = _client._plcConnection.ReadBoolean("DB562.DBX 2.0");
                if (bOK == true)
                {
                    Thread.Sleep(_iTimer);
                    bOK = _client._plcConnection.ReadBoolean("DB562.DBX 2.0");
                }
                break;

            default:
                ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": wrong Telegramtype.");
                return(false);
            }
            return(bOK);
        }
Esempio n. 6
0
 private int sendTelegramToMainWin(TelegramType teleType, object[] senderInfo, DCPFrame repmsg)
 {
     _teleToWin = new Telegram(_teleFromWin.data.Capacity);
     _teleToWin.copy(_teleFromWin);
     _teleToWin.uniqId = GlobalServices.uniqTelegramId();
     _teleToWin.parentUniqId = _teleFromWin.uniqId;
     _teleToWin.type = teleType;
     _teleToWin.protocol = Protocol.DCP2;
     if (repmsg.Len >= 2)
     {
         _teleToWin.data.copy(repmsg.Data, repmsg.Len - 2);
     }
     _teleToWin.replySize = _teleFromWin.replySize;
     _teleToWin.mainWin = _teleFromWin.mainWin;
     _teleToWin.portHandler = this;
     _teleToWin.appFuncId = _teleFromWin.appFuncId;
     _teleToWin.userData = _teleFromWin.userData;
     _teleToWin.setNoHeader();
     _teleToWin.DCPMsgType = repmsg.MsgType;
     _teleToWin.DCPCmdSet = repmsg.CmdSet;
     _teleToWin.SenderInfo = senderInfo;
     try
     {
         if ((teleType == TelegramType.SeriesEndOK) || (teleType == TelegramType.SeriesEndERROR))
         {
             ((Form) _mainWin).BeginInvoke(new TelegramReceiver(_mainWin.telegramFromPortHandler), new object[] { _teleToWin });
         }
         else
         {
             ((Form) _mainWin).Invoke(new TelegramReceiver(_mainWin.telegramFromPortHandler), new object[] { _teleToWin });
         }
     }
     catch (Exception exception)
     {
         _log.Error("IOPH_DATA: Invoking telegramFromPortHandler 2 failed: (TelegramType = " + teleType.ToString() + ")" + exception.Message);
     }
     return 0;
 }
Esempio n. 7
0
 private int sendTelegramToMainWin(TelegramType teleType, object[] senderInfo)
 {
     _teleToWin = new Telegram(_teleFromWin.data.Capacity);
     _teleToWin.copy(_teleFromWin);
     _teleToWin.uniqId = GlobalServices.uniqTelegramId();
     _teleToWin.parentUniqId = _teleFromWin.uniqId;
     _teleToWin.type = teleType;
     _teleToWin.protocol = _teleFromWin.protocol;
     _teleToWin.data.NumItems = 0;
     _teleToWin.replySize = 0;
     _teleToWin.mainWin = _teleFromWin.mainWin;
     _teleToWin.portHandler = this;
     _teleToWin.appFuncId = _teleFromWin.appFuncId;
     _teleToWin.userData = _teleFromWin.userData;
     _teleToWin.SenderInfo = senderInfo;
     if (senderInfo != null)
     {
         _teleToWin.UserDataExt.addUserData("SenderInfo", (string) senderInfo[0]);
     }
     _teleToWin.setNoHeader();
     try
     {
         if (((teleType == TelegramType.SeriesEndOK) || (teleType == TelegramType.SeriesEndERROR)) || (teleType == TelegramType.PortHandlerTerminated))
         {
             ((Form) _mainWin).BeginInvoke(new TelegramReceiver(_mainWin.telegramFromPortHandler), new object[] { _teleToWin });
         }
         else
         {
             ((Form) _mainWin).Invoke(new TelegramReceiver(_mainWin.telegramFromPortHandler), new object[] { _teleToWin });
         }
     }
     catch (Exception exception)
     {
         _log.Error("IOPH_DATA: Invoking telegramFromPortHandler 1 failed: (TelegramType = " + teleType.ToString() + ")" + exception.Message);
     }
     return 0;
 }
Esempio n. 8
0
 public Telegram(TelegramType type = TelegramType.Query)
 {
     Type    = type;
     Date    = DateTime.Now;
     Content = new Node();
 }
Esempio n. 9
0
 private int SendCommandTelegram(string command, TelegramType teleType, Protocol protocol, int replySize, Task opType, int devRegIdx)
 {
     try
     {
         this._tele = new Telegram((20 > command.Length) ? 20 : command.Length);
         this._task_id = opType;
         this._tele.uniqId = GlobalServices.uniqTelegramId();
         this._tele.parentUniqId = -1;
         this._tele.type = teleType;
         this._tele.protocol = protocol;
         this._tele.portHandler = this._ioph;
         this._tele.userData = devRegIdx;
         this._tele.data.NumItems = command.Length;
         for (int i = 0; i < this._tele.data.NumItems; i++)
         {
             this._tele.data[i] = (byte) command[i];
         }
         this._tele.replySize = replySize;
         this._tele.mainWin = this;
         this._isSeries = true;
         this._series.clear();
         this._series.addTelegram(this._tele);
         if (this._ioph.telegramSeriesFromMainWin(this._series, SeriesExecutionState.Run, true) == 0)
         {
             this._isDeviceBusy = true;
             GlobalServices.LogMsg(this._appId, "Set Loadboard Led Series started");
             return 0;
         }
         return -1;
     }
     catch (Exception exception)
     {
         MessageBox.Show("Error at SendCommandTelegram!\n" + exception.Message);
         return -1;
     }
 }
Esempio n. 10
0
 private int sendTelegramToMainWin(TelegramType teleType, Protocol protocol, DataBuffer dataPacket)
 {
     this._teleToWin.uniqId = GlobalServices.uniqTelegramId();
     this._teleToWin.parentUniqId = -1;
     this._teleToWin.type = teleType;
     this._teleToWin.protocol = protocol;
     this._teleToWin.data.copy(dataPacket);
     this._teleToWin.replySize = -1;
     this._teleToWin.mainWin = null;
     this._teleToWin.portHandler = this;
     this._teleToWin.appFuncId = -1;
     this._teleToWin.userData = this._dllFuncRetVal;
     this._teleToWin.setNoHeader();
     if (teleType == TelegramType.DeviceFailure)
     {
         GlobalServices.ErrMsg("sendTelegramToMainWin('DeviceFailure', " + dataPacket.objectInfo(true) + ")", "DeviceFailure telegram will be sent !");
     }
     try
     {
         if (this._isSeries)
         {
             if ((teleType == TelegramType.SeriesEndOK) || (teleType == TelegramType.SeriesEndERROR))
             {
                 ((Form) this._mainWin).BeginInvoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
             }
             else
             {
                 ((Form) this._mainWin).Invoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
             }
         }
         else
         {
             ((Form) this._mainWin).BeginInvoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
         }
     }
     catch
     {
         GlobalServices.ErrMsg("IOPH_EZLinkDongle", "Invoking telegramFromPortHandler failed");
     }
     return 0;
 }
Esempio n. 11
0
 private int sendTelegramToMainWin(TelegramType teleType)
 {
     this._teleToWin.uniqId = GlobalServices.uniqTelegramId();
     this._teleToWin.parentUniqId = this._teleFromWin.uniqId;
     this._teleToWin.type = teleType;
     this._teleToWin.protocol = this._teleFromWin.protocol;
     this._teleToWin.data.NumItems = 0;
     this._teleToWin.replySize = 0;
     this._teleToWin.mainWin = this._teleFromWin.mainWin;
     this._teleToWin.portHandler = this;
     this._teleToWin.appFuncId = this._teleFromWin.appFuncId;
     this._teleToWin.userData = this._dllFuncRetVal;
     this._teleToWin.setNoHeader();
     if (teleType == TelegramType.DeviceFailure)
     {
         GlobalServices.ErrMsg("sendTelegramToMainWin('DeviceFailure')", "DeviceFailure telegram will be sent !");
     }
     try
     {
         if (this._isSeries)
         {
             if ((teleType == TelegramType.SeriesEndOK) || (teleType == TelegramType.SeriesEndERROR))
             {
                 ((Form) this._mainWin).BeginInvoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
             }
             else
             {
                 ((Form) this._mainWin).Invoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
             }
         }
         else
         {
             ((Form) this._mainWin).BeginInvoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
         }
     }
     catch
     {
         GlobalServices.ErrMsg("IOPH_EZLink", "Invoking telegramFromPortHandler failed");
     }
     return 0;
 }
Esempio n. 12
0
File: Telegram.cs Progetto: x893/WDS
 public int copy(Telegram another)
 {
     this.data.copy(another.data);
     this.uniqId = another.uniqId;
     this.parentUniqId = another.parentUniqId;
     this.type = another.type;
     this.lastReplyPrecondition = another.lastReplyPrecondition;
     this.numOfLastReplyPackets = another.numOfLastReplyPackets;
     this._TimeOut = another.TimeOut;
     this._userData = another._userData;
     this._userDataExt.copy(another.UserDataExt);
     this.CallbackEvent = another.CallbackEvent;
     this.protocol = another.protocol;
     this.replySize = another.replySize;
     this.mainWin = another.mainWin;
     this.portHandler = another.portHandler;
     this.appFuncId = another.appFuncId;
     this.userData = another.userData;
     this._hasHeader = another.HasHeader;
     this.DCPCmdSet = another.DCPCmdSet;
     this.DCPMsgType = another.DCPMsgType;
     return 0;
 }
Esempio n. 13
0
File: Telegram.cs Progetto: x893/WDS
 public void clear()
 {
     int num;
     this.replySize = num = -1;
     this.uniqId = this.parentUniqId = num;
     this.type = 0;
     this.lastReplyPrecondition = LastReplyPrecondition.Unknown;
     this.numOfLastReplyPackets = -1;
     this.protocol = Protocol.Invalid;
     this.data.NumItems = 0;
     this.replySize = -1;
     this.appFuncId = -1;
     this.userData = -1;
     this._hasHeader = false;
     this.DCPCmdSet = 0;
     this.DCPMsgType = 0;
     this.UserDataExt.clear();
 }
Esempio n. 14
0
 private int sendTelegramToMainWin(TelegramType teleType)
 {
     this._teleToWin.uniqId = GlobalServices.uniqTelegramId();
     this._teleToWin.parentUniqId = this._teleFromWin.uniqId;
     this._teleToWin.type = teleType;
     this._teleToWin.protocol = this._teleFromWin.protocol;
     this._teleToWin.data.NumItems = 0;
     this._teleToWin.replySize = 0;
     this._teleToWin.mainWin = this._teleFromWin.mainWin;
     this._teleToWin.portHandler = this;
     this._teleToWin.appFuncId = this._teleFromWin.appFuncId;
     this._teleToWin.userData = this._teleFromWin.userData;
     this._teleToWin.setNoHeader();
     try
     {
         if (this._isSeries)
         {
             if ((teleType == TelegramType.SeriesEndOK) || (teleType == TelegramType.SeriesEndERROR))
             {
                 ((Form) this._mainWin).BeginInvoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
             }
             else
             {
                 ((Form) this._mainWin).Invoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
             }
         }
         else
         {
             ((Form) this._mainWin).BeginInvoke(new TelegramReceiver(this._mainWin.telegramFromPortHandler), new object[] { this._teleToWin });
         }
     }
     catch (Exception exception)
     {
         GlobalServices.ErrMsg("IOPH_LoadBoard", "Invoking telegramFromPortHandler failed: " + exception.Message);
     }
     return 0;
 }