/// <summary>
 /// 连接成功,读取堆垛机信息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GetSCStatusTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (srs.Port == "4000")
     {
         if (!crs.Send(MessageHeader_4000))
         {
             CheckConnectTimer.Start();
             GetSCStatusTimer.Stop();
         }
     }
     else if (srs.Port == "6000")
     {
         if (srs.Name == "HC001")
         {
             if (!crs.Send(MessageHeaderHC_6000))
             {
                 CheckConnectTimer.Start();
                 GetSCStatusTimer.Stop();
             }
         }
         else
         {
             if (!crs.Send(MessageHeader_6000))
             {
                 CheckConnectTimer.Start();
                 GetSCStatusTimer.Stop();
             }
         }
     }
 }
Beispiel #2
0
 private void GetSCStatusTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (m_strport == "4000")
     //if (m_strport == "80")
     {
         if (!OSRM.SendMsg(MessageHeader_4000))
         {
             CheckConnectTimer.Start();
             GetSCStatusTimer.Stop();
         }
     }
     else if (m_strport == "6000")
     {
         if (m_strSRMNo == "HC001")
         {
             if (!OSRM.SendMsg(MessageHeaderHC_6000))
             {
                 CheckConnectTimer.Start();
                 GetSCStatusTimer.Stop();
             }
         }
         else
         {
             if (!OSRM.SendMsg(MessageHeader_6000))
             {
                 CheckConnectTimer.Start();
                 GetSCStatusTimer.Stop();
             }
         }
     }
 }
Beispiel #3
0
        public Server()
        {
            IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 5555);

            CurrentAddress.Bind(ipep);
            CurrentAddress.Listen(100);

            CheckConnectTimer.Elapsed += TryConnectClient;
            CheckConnectTimer.Start();
        }
Beispiel #4
0
        private void OSRM_AnalyseMessageEvent(string CommandType, object msg)
        {
            CRCObjectB findcob = crclistB.Find(
                delegate(CRCObjectB info)
            {
                return(info.ScNo == m_strSRMNo && info.Port == int.Parse(m_strport));
            }
                );

            if (m_strport == "4000" && CommandType == "RecvData")
            //if (m_strport == "80" && CommandType == "RecvData")
            {
                if (findcob != null)
                {
                    findcob.connectstatus = (findcob.connectstatus == 1 ? 2 : 1);
                }
                crcb.UpdateCRCStatus(m_strSRMNo, msg.ToString(), aisle.ToString());
                if (!string.IsNullOrEmpty(crcb.GetAlarmInfo(m_strSRMNo, "", false)))
                {
                    log.WriteLog(crcb.GetAlarmInfo(m_strSRMNo, "", false));
                }
                if (ENotifyTypeEventHandler != null)
                {
                    ENotifyTypeEventHandler(m_strSRMNo, m_strport, CommandType, msg);
                }
            }
            else if (m_strport == "6000" && CommandType == "RecvData")
            {
                crcb.GetAlarmInfo(m_strSRMNo, msg.ToString(), true);
            }
            else if (CommandType == "Break")
            {
                if (findcob != null)
                {
                    findcob.connectstatus = 0;
                }
                CheckConnectTimer.Start();
                GetSCStatusTimer.Stop();
                dal.UpdateSCStatusNTI(m_strSRMNo, "Equipment_Error");
                crcb.UpdateCRCStatus(m_strSRMNo, CommandType, aisle.ToString());
                //ShowText("C", "连接中断,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
            }
            else if (CommandType == "Connect")
            {
                if (findcob != null)
                {
                    findcob.connectstatus = 1;
                }
                CheckConnectTimer.Stop();
                GetSCStatusTimer.Start();
                ShowText("C", "连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
            }
        }
Beispiel #5
0
 private void CheckConnectTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (OSRM.Startup())
     {
         GetSCStatusTimer.Start();
         CheckConnectTimer.Stop();
         ShowText("C", "检测连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
     }
     else
     {
         ShowText("C", "检测连接失败,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
     }
 }
 public void Run()
 {
     //判断连接
     if (crs.Connect(srs.Ip, srs.Port))
     {
         GetSCStatusTimer.Start();
         NotifyShowEvent?.Invoke("C", $"连接成功,IP地址{srs.Ip},堆垛机名称{srs.Name},端口{srs.Port}");
     }
     else
     {
         CheckConnectTimer.Start();
         NotifyShowEvent?.Invoke("C", $"连接失败,IP地址{srs.Ip},堆垛机名称{srs.Name},端口{srs.Port}");
     }
 }
Beispiel #7
0
 private void CheckConnectTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (OSRM.Connection())
     {
         ShowText("C", "Socket连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
         // log.WriteLog("********************************************");
         // log.WriteLog("Socket连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
         // log.WriteLog("********************************************");
         //OSRM.Initialized(m_strSRMNo);
         CheckConnectTimer.Stop();
     }
     else
     {
         CheckConnectTimer.Start();
         //GetSCStatusTimer.Stop();
         log.WriteLog("Socket连接失败,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
         ShowText("C", "Socket连接失败,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
     }
 }
Beispiel #8
0
 private void GetSCStatusTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     //if (!OSRM.RequestSRMState())
     if (!OSRM.ReStart(m_strSRMNo))
     {
         CheckConnectTimer.Start();
         //GetSCStatusTimer.Stop();
     }
     //if (i_Flag >= 5)
     //{
     //    if (!OSRM.SRMHeartCheck(m_strSRMNo))//发送心跳
     //    {
     //        ShowText("C", m_strSRMNo + "系统异常,Socket通信连接中断,心跳指令不能发送!");
     //        CheckConnectTimer.Start();
     //        GetSCStatusTimer.Stop();
     //    }
     //    i_Flag = 1;
     //}
     //i_Flag++;
 }
Beispiel #9
0
 public int Run()//启动
 {
     if (OSRM.Startup())
     {
         if (m_strport == "4000")
         //if (m_strport == "80")
         {
             CRCStatusB status = new CRCStatusB();
             status.CRCNum      = m_strSRMNo;
             status.AisleNumber = aisle.ToString();
             CRCItemsB.Add(status);
         }
         GetSCStatusTimer.Start();
         ShowText("C", "连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
         return(1);
     }
     else
     {
         CheckConnectTimer.Start();
         ShowText("C", "连接失败,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
         return(0);
     }
 }
        /// <summary>
        /// 如果连接失败,定时检测网络,网络正常则自动连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CheckConnectTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            List <CRCObject> crclist = new List <CRCObject>();
            CRCObject        findCob = crclist.Find(info => info.ScNo == srs.Name && info.Port == int.Parse(srs.Port));

            if (crs.Connect(srs.Ip, srs.Port))
            {
                GetSCStatusTimer.Start();
                CheckConnectTimer.Stop();
                if (findCob != null)
                {
                    findCob.connectstatus = 1;
                }
                NotifyShowEvent?.Invoke("C", $"检测连接成功,IP地址{srs.Ip},堆垛机编号{srs.Name},端口{srs.Port}");
            }
            else
            {
                NotifyShowEvent?.Invoke("C", $"检测连接失败,IP地址{srs.Ip},堆垛机编号{srs.Name},端口{srs.Port}");
                if (findCob != null)
                {
                    findCob.connectstatus = 0;
                }
            }
        }
Beispiel #11
0
 public int Run()//启动
 {
     if (OSRM.Startup())
     {
         CheckConnectTimer.Stop();
         //GetSCStatusTimer.Stop();
         //CRNStatus status = new CRNStatus();
         //status.CRCNum = m_strSRMNo;
         //status.Zone = m_zone;
         //status.AisleNumber = aisle.ToString();
         //CRNList.Add(status);
         ShowText("C", "连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
         //log.WriteLog("********************************************");
         //log.WriteLog("连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport);
         //log.WriteLog("********************************************");
         return(1);
     }
     else
     {
         CheckConnectTimer.Start();
         //GetSCStatusTimer.Stop();
         return(0);
     }
 }
Beispiel #12
0
        private void OSRM_AnalyseMessageEvent(NotifyCommand command, string msg)
        {
            CRNObject findcob = CRNOBList.Find(
                delegate(CRNObject info)
            {
                //return (info.ScNo == m_strSRMNo && info.Port == int.Parse(m_strport) && info.zone == m_zone);
                return(info.ScNo == m_strSRMNo && info.Port == int.Parse(m_strport) && info.zone == m_zone);
                //"CRN00" + msg.Substring(41, 1)
            }
                );

            try
            {
                string alarmMsg = "";
                if (command == NotifyCommand.Connect)
                {
                    CheckConnectTimer.Stop();
                    findcob.connectstatus = 1;
                    alarmMsg = crc.UpdateSCStatus(m_strSRMNo, "Connect", m_strSRMNo.Substring(5, 1), m_zone);
                    ShowText("C", msg);
                }
                else if (command == NotifyCommand.RecvData)
                {
                    string mesgs = msg;
                    //if (mesgs.Substring(1, 2) == "LA")
                    //{
                    //    //GetSCStatusTimer.Start();//建立连接结束,开始心跳检测
                    //    mesgs.Substring(0, mesgs.Length);
                    //}
                    //string num = "CRN00" + (int.Parse(msg.Substring(41, 1))+2);//m_strSRMNo;
                    string num = m_strSRMNo;
                    if (mesgs.Substring(1, 2) == "LD")
                    {
                        OSRM.ReturnLDMsg(mesgs.Substring(3, 13));
                    }
                    if (m_strSRMNo == "CRN006")
                    {
                        num = "CRN00" + mesgs.Substring(mesgs.Length - 2, 1);
                    }
                    alarmMsg = crc.UpdateSCStatus(num, mesgs, m_strSRMNo.Substring(5, 1), m_zone);

                    if (!string.IsNullOrEmpty(alarmMsg))
                    {
                        ShowText("", alarmMsg);
                        if (mesgs.Substring(1, 2) != "LA")
                        {
                            log.WriteLog(alarmMsg);
                        }
                    }
                }
                else if (command == NotifyCommand.SendData)
                {
                    //ShowText("", msg);
                }
                else if (command == NotifyCommand.Break)
                {
                    CheckConnectTimer.Start();
                    alarmMsg = crc.UpdateSCStatus(m_strSRMNo, "Break", m_strSRMNo.Substring(5, 1), m_zone);
                    findcob.connectstatus = 0;
                    if (!string.IsNullOrEmpty(alarmMsg))
                    {
                        ShowText("", alarmMsg);
                    }
                }
                if (ENotifyTypeEventHandler != null)
                {
                    ENotifyTypeEventHandler(m_strSRMNo, m_strport, "", msg);
                }
            }
            catch (Exception ex)
            {
                //log.WriteLog("********************************************");
                //log.WriteLog("错误信息:" + ex.Message);
                //log.WriteLog("********************************************");
            }
        }