Esempio n. 1
0
        private void DealMessage(object wh)
        {
            try
            {
                int warehouse = Convert.ToInt32(wh);
                if (!dic_WorkFlows.ContainsKey(warehouse))
                {
                    log.Error("dic_WorkFlows没有包含key-" + warehouse + " 系统无法启动!");
                    return;
                }
                WorkFlow controller = dic_WorkFlows[warehouse];
                try
                {
                    controller.ConnectPLC();
                }
                catch (Exception ex)
                {
                    log.Error("连接PLC异常,无法打开连接!系统无法启动!" + ex.ToString());
                    //return;
                }
                while (isStart)
                {
                    try
                    {
                        controller.DealFaultAlarmAndStatusWord();
                        controller.TaskAssign();
                        controller.ReceiveMessage();
                        controller.SendMessage();

                        Thread.Sleep(plcRefresh);
                    }
                    catch (Exception ec)
                    {
                        log.Error("处理业务异常-" + ec.ToString());
                        Thread.Sleep(15000);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
        }