Exemplo n.º 1
0
        /// <summary>
        /// 继电器设备逐个自检
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public RelayProtocol.Err_r SelfCheckOneByOne(RelayProtocol.Cmd_r cmd, bool status)
        {
            RelayProtocol.Err_r err = RelayProtocol.Err_r.NoError;
            err = ryDeviceProtocol.WriteRelayStatus(cmd, status);

            // 记录辅槽制冷的关闭时间
            if (cmd == RelayProtocol.Cmd_r.SubCool && status == false)
            {
                subCoolCloseTime = DateTime.Now;
            }

            return(err);
        }
Exemplo n.º 2
0
        internal RelayProtocol.Err_r UpdateStatusToDeviceReturnErr()
        {
            RelayProtocol.Err_r err = RelayProtocol.Err_r.NoError;
            lock (ryLocker)
            {
                // 遍历枚举类型 RelayProtocol.Cmd_r 中所有的值
                foreach (RelayProtocol.Cmd_r cmd in Enum.GetValues(typeof(RelayProtocol.Cmd_r)))
                {
                    // 如果要设置的继电器状态与当前状态相同,则跳过
                    if (ryStatus[(int)cmd] == ryStatusToSet[(int)cmd])
                    {
                        continue;
                    }

                    err = ryDeviceProtocol.WriteRelayStatus(cmd, ryStatusToSet[(int)cmd]);
                    // 暂停一段时间
                    Thread.Sleep(20);
                    // 调试信息
                    Debug.WriteLineIf(err == RelayProtocol.Err_r.NoError, "继电器 " + cmd.ToString() + " 状态更新成功!  " + ryStatusToSet[(int)cmd].ToString());
                    Debug.WriteLineIf(err != RelayProtocol.Err_r.NoError, "继电器 " + cmd.ToString() + " 状态更新失败!  " + err.ToString());

                    // 如果正确关闭了辅槽制冷,则记录其关闭时间
                    if (cmd == RelayProtocol.Cmd_r.SubCool && ryStatusToSet[(int)cmd] == false && err == RelayProtocol.Err_r.NoError)
                    {
                        subCoolCloseTime = DateTime.Now;
                        subCoolWaiting   = false;
                    }


                    if (err == RelayProtocol.Err_r.NoError)
                    {
                        // 设置继电器状态成功,更新 ryStatus[] 中的值
                        ryStatus[(int)cmd] = ryStatusToSet[(int)cmd];
                    }
                    else
                    {
                        // 设置继电器状态失败,结束 for 循环
                        break;
                    }
                }
            }


            // 触发设备错误事件,并返回设置错误信息
            StatusUpdateToDeviceEvent(err);

            return(err);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 继电器设备自检
        /// </summary>
        /// <returns></returns>
        public RelayProtocol.Err_r SelfCheck()
        {
            RelayProtocol.Err_r err = RelayProtocol.Err_r.NoError;
            /////////////////////////////////////////////////////////////////////////
            // 打开总电源开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.Elect, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 打开主槽控温开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.MainHeat, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 打开辅槽控温开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.SubHeat, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 打开辅槽制冷源开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.SubCool, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 打开辅槽循环开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.SubCircle, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 打开主槽快冷开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.MainCoolF, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 打开辅槽快冷开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.SubCoolF, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 打开海水进开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.WaterIn, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 打开海水出开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.WaterOut, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);

            /////////////////////////////////////////////////////////////////////////
            // 关闭海水出开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.WaterOut, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 关闭海水进开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.WaterIn, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 关闭辅槽快冷开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.SubCoolF, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 关闭主槽快冷开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.MainCoolF, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 关闭辅槽循环开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.SubCircle, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 关闭辅槽制冷源开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.SubCool, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            // 记录辅槽制冷关闭时间
            subCoolCloseTime = DateTime.Now;
            Thread.Sleep(1000);
            // 关闭辅槽控温开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.SubHeat, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 关闭主槽控温开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.MainHeat, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);
            // 关闭总电源开关
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.Elect, false);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }
            Thread.Sleep(1000);

            //////////////////////////
            // 最后,打开总电源
            err = ryDeviceProtocol.WriteRelayStatus(RelayProtocol.Cmd_r.Elect, true);
            if (err != RelayProtocol.Err_r.NoError)
            {
                return(err);
            }

            return(RelayProtocol.Err_r.NoError);
        }