Example #1
0
        private void ResetAlm()
        {
            Flag.MenuChangeState = false;

            Flag.RunLogList.Add("系统复位中……", Color.Orange);

            #region  位Adam的连接状态
            for (int i = 0; i < Flag.Manufacturer.Network.Modular.Length; i++)
            {
                if (Adam.IsConnect(i) == false)
                {
                    Flag.RunLogList.Add("远程IO模块" + (i + 1).ToString() + "断线重接中……");
                    if (Adam.Reconnect(i) == true)
                    {
                        Flag.RunLogList.Add("远程IO模块" + (i + 1).ToString() + "连接成功!", Color.Green);
                    }
                    else
                    {
                        Flag.RunLogList.Add("远程IO模块" + (i + 1).ToString() + "连接失败!", Color.Red);
                    }
                }
            }
            #endregion

            #region  位A6的连接状态

            bool IsConnent = false;

            for (int i = 0; i < Flag.Unit.Length; i++)
            {
                IsConnent = IsConnent || Flag.Unit[i].InternalPump.IsConnent;

                if (Flag.Unit[i].InternalPump.IsErr == true)
                {
                    for (int j = 0; j < PanasonicA6.A6_ErrCodeList.Length; j++)
                    {
                        if (Flag.Unit[i].InternalPump.ErrCode == PanasonicA6.A6_ErrCodeList[j].Code && PanasonicA6.A6_ErrCodeList[j].IsClear == true)
                        {
                            if (PanasonicA6.A6_ErrCodeList[j].IsClear == true)
                            {
                                Flag.RunLogList.Add("内循环泵" + (i + 1).ToString() + "报警清除中……");
                                if (Work.Pump.ClearErr(Flag.Unit[i].InternalPump.Address) == true)
                                {
                                    Flag.RunLogList.Add("内循环泵" + (i + 1).ToString() + "报警清除成功!", Color.Green);
                                }
                                else
                                {
                                    Flag.RunLogList.Add("内循环泵" + (i + 1).ToString() + "报警清除失败!", Color.Red);
                                }
                            }
                            else
                            {
                                Flag.RunLogList.Add("内循环泵" + (i + 1).ToString() + "报警代码:" + Flag.Unit[i].InternalPump.ErrCode + "无法清除!");
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < Flag.ExternalPump.Length; i++)
            {
                IsConnent = IsConnent || Flag.ExternalPump[i].IsConnent;

                if (Flag.ExternalPump[i].IsErr == true)
                {
                    for (int j = 0; j < PanasonicA6.A6_ErrCodeList.Length; j++)
                    {
                        if (Flag.ExternalPump[i].ErrCode == PanasonicA6.A6_ErrCodeList[j].Code)
                        {
                            if (PanasonicA6.A6_ErrCodeList[j].IsClear == true)
                            {
                                Flag.RunLogList.Add("外循环泵" + (i + 1).ToString() + "报警清除中……");
                                if (Work.Pump.ClearErr(Flag.ExternalPump[i].Address) == true)
                                {
                                    Flag.RunLogList.Add("外循环泵" + (i + 1).ToString() + "报警清除成功!", Color.Green);
                                }
                                else
                                {
                                    Flag.RunLogList.Add("外循环泵" + (i + 1).ToString() + "报警清除失败!", Color.Red);
                                }
                            }
                            else
                            {
                                Flag.RunLogList.Add("外循环泵" + (i + 1).ToString() + "报警代码:" + Flag.ExternalPump[i].ErrCode + "无法清除!");
                            }
                        }
                    }
                }
            }

            if (IsConnent == false)
            {
                PanasonicA6.Open();
            }
            #endregion

            #region  位Handler的连接状态
            if (Handler.NNodbusSlave != null)
            {
                if (Handler.IsConnect == false)
                {
                    Handler.Open();
                }
            }
            else
            {
                if (Handler.Initialization("COM3", 115200) == true)
                {
                    Flag.RunLogList.Add("初始化Handler连接已完成,等待设备连接!", Color.Green);
                }
                else
                {
                    Flag.RunLogList.Add("初始化Handler连接失败!", Color.Red);
                }
            }

            #endregion

            Flag.MenuChangeState = true;
        }
Example #2
0
        /// <summary>
        /// 获取所对应研华模块的连接状态
        /// </summary>
        /// <param name="Index">研华模型系统里对应的序号</param>
        /// <returns>连接或未连接</returns>
        public static bool IsConnect(int Index)
        {
            int  Id_Num    = -1;
            bool IsConnect = false;

            switch (Adam.GetAdamType(Index, ref Id_Num))
            {
            case Adam.HaveAdamType.AdamModule6017:

                if (Adam6017 != null)
                {
                    IsConnect = Adam6017[Id_Num].IsComR && Adam6017[Id_Num].IsComT;
                }
                else
                {
                    IsConnect = false;
                }

                break;

            case Adam.HaveAdamType.AdamModule6018:

                if (Adam6018 != null)
                {
                    IsConnect = Adam6018[Id_Num].IsComR && Adam6018[Id_Num].IsComT;
                }
                else
                {
                    IsConnect = false;
                }
                break;

            case Adam.HaveAdamType.AdamModule6250:

                if (Adam6250 != null)
                {
                    IsConnect = Adam6250[Id_Num].IsComR && Adam6250[Id_Num].IsComT;
                }
                else
                {
                    IsConnect = false;
                }

                break;

            case Adam.HaveAdamType.AdamModule6256:

                if (Adam6256 != null)
                {
                    IsConnect = Adam6256[Id_Num].IsComR && Adam6256[Id_Num].IsComT;
                }
                else
                {
                    IsConnect = false;
                }

                break;

            default:

                IsConnect = false;

                break;
            }

            return(IsConnect);
        }