/// <summary>
        /// 当前温度
        /// </summary>
        /// <param name="isShowStatus">温度检测不正常时,是否显示状态 True:显示 False:不显示</param>
        /// <returns></returns>
        public static string Dictionary_NowTmp(int vendBoxIndex, bool isShowStatus)
        {
            string strNowTmp = string.Empty;

            try
            {
                if (PubHelper.p_BusinOper.AsileOper.VendBoxList[vendBoxIndex].TmpStatus == "00")
                {
                    int intTmpValue = Convert.ToInt32(PubHelper.p_BusinOper.AsileOper.VendBoxList[vendBoxIndex].TmpValue);
                    BusinessEnum.TmpControlModel tmpControlModel = PubHelper.p_BusinOper.AsileOper.VendBoxList[vendBoxIndex].TmpControlModel;
                    bool blnIsShowValue = false;
                    // 温度检测正常
                    if (tmpControlModel == BusinessEnum.TmpControlModel.Refrigeration)
                    {
                        // 如果是制冷
                        if ((intTmpValue >= 0) && (intTmpValue <= 60))
                        {
                            blnIsShowValue = true;
                        }
                    }
                    if (tmpControlModel == BusinessEnum.TmpControlModel.Heating)
                    {
                        // 如果是加热
                        if ((intTmpValue >= 0) && (intTmpValue < 100))
                        {
                            blnIsShowValue = true;
                        }
                    }
                    if (blnIsShowValue)
                    {
                        strNowTmp = intTmpValue.ToString() + PubHelper.TMP_UNIT;
                    }
                }
                else
                {
                    if (isShowStatus)
                    {
                        switch (PubHelper.p_BusinOper.AsileOper.VendBoxList[vendBoxIndex].TmpStatus)
                        {
                        case "01":                                                                  //
                            strNowTmp = PubHelper.p_LangOper.GetStringBundle("Pub_Device_Tmp_Out"); // "检测超限";
                            break;

                        case "02":                                                                      //
                            strNowTmp = PubHelper.p_LangOper.GetStringBundle("Pub_Device_Tmp_Connect"); // "未连接";
                            break;
                        }
                    }
                }
            }
            catch
            {
            }

            return(strNowTmp);
        }
Example #2
0
        public static BusinessEnum.TmpControlModel ChangeTmpControlModel(string controlModel)
        {
            BusinessEnum.TmpControlModel model = BusinessEnum.TmpControlModel.Refrigeration;
            switch (controlModel)
            {
            case "1":    // 加热
                model = BusinessEnum.TmpControlModel.Heating;
                break;

            default:
                model = BusinessEnum.TmpControlModel.Refrigeration;
                break;
            }

            return(model);
        }
        /// <summary>
        /// 检测制冷压缩机设备是否需要改变当前状态,只针对制冷压缩机
        /// </summary>
        /// <param name="deviceModel">压缩机控制策略</param>
        /// <param name="doorStatus">当前门状态</param>
        /// <param name="nowTmpValue">当前温度</param>
        /// <returns></returns>
        public static BusinessEnum.DeviceControlStatus CheckRefControlRole(DeviceControlModel deviceModel,
                                                                           BusinessEnum.TmpControlModel tmpControlModel,
                                                                           string doorStatus, string nowTmpStatus, string nowTmpValue, string targetTmp)
        {
            /* 制冷压缩机控制策略
             * 1、开机后,如果压缩机需要打开,则需要等待7分钟
             * 2、压缩机连续工作50分钟后,必须要关闭
             * 3、压缩机下次打开时,必须距离上次关闭的时间超过7分钟
             * 4、当前温度达到最低温度,则关闭压缩机
             * 5、门开后,关闭压缩机
             */

            BusinessEnum.DeviceControlStatus deviceControlStatus = BusinessEnum.DeviceControlStatus.Keep;

            try
            {
                deviceControlStatus = CheckDeviceControlRole(deviceModel);

                if (deviceControlStatus == BusinessEnum.DeviceControlStatus.Open)
                {
                    // 如果此时从时间上检测需要打开压缩机
                    bool blnIsOpen = true;// 是否能打开压缩机 False:不能 True:打开

                    #region 其它条件检测压缩机是否能打开

                    doorStatus = "00";
                    if (doorStatus == "01")
                    {
                        // 此时门开,则不能打开压缩机
                        blnIsOpen = false;
                    }
                    else
                    {
                        blnIsOpen = true;

                        if (tmpControlModel == BusinessEnum.TmpControlModel.Refrigeration)
                        {
                            // 制冷情况:如果当前温度超过了最低温度,则不能打开压缩机
                            if ((nowTmpStatus == "00") && (Convert.ToInt32(nowTmpValue) <= Convert.ToInt32(targetTmp)))
                            {
                                blnIsOpen = false;
                            }
                        }
                        if (tmpControlModel == BusinessEnum.TmpControlModel.Heating)
                        {
                            // 加热情况:如果当前温度超过了最高温度,则不能打开加热器
                            if ((nowTmpStatus == "00") && (Convert.ToInt32(nowTmpValue) >= Convert.ToInt32(targetTmp)))
                            {
                                blnIsOpen = false;
                            }
                        }

                        if (blnIsOpen)
                        {
                            // 如果距离上次关闭时间不足7分钟,则不能打开压缩机
                            DateTime dtmNowTime = DateTime.Now;

                            TimeSpan ts1 = new TimeSpan(deviceModel.LastCloseTime.Ticks);
                            TimeSpan ts2 = new TimeSpan(dtmNowTime.Ticks);
                            TimeSpan ts  = ts1.Subtract(ts2).Duration();
                            if (ts.Minutes < deviceModel.CloseDelayTime)
                            {
                                // 距离上次压缩机关闭时间不足7分钟
                                blnIsOpen = false;
                            }
                        }
                    }

                    #endregion

                    if (!blnIsOpen)
                    {
                        // 压缩机不能打开,需要关闭
                        switch (deviceModel.ControlStatus)
                        {
                        case BusinessEnum.DeviceControlStatus.Close:    // 如果当前压缩状态已经为关闭,则状态保持不变
                            deviceControlStatus = BusinessEnum.DeviceControlStatus.Keep;
                            break;

                        case BusinessEnum.DeviceControlStatus.Open:    // 如果当前压缩机状态已经为打开,则状态切换为关闭
                            deviceControlStatus = BusinessEnum.DeviceControlStatus.Close;
                            break;
                        }
                    }
                }

                if ((deviceModel.ControlStatus == BusinessEnum.DeviceControlStatus.Open) &&
                    (deviceControlStatus == BusinessEnum.DeviceControlStatus.Keep))
                {
                    // 压缩机当前状态如果为已经打开且当前需要切换的状态为保持打开状态,则检测打开的连续时间是否超过了规定的最大时间,如果超过,则关闭;如果没有超过,则保持
                    if ((nowTmpStatus == "00") &&
                        (tmpControlModel == BusinessEnum.TmpControlModel.Refrigeration) &&
                        (Convert.ToInt32(nowTmpValue) <= Convert.ToInt32(targetTmp)))
                    {
                        deviceControlStatus = BusinessEnum.DeviceControlStatus.Close;
                    }
                    else if ((nowTmpStatus == "00") &&
                             (tmpControlModel == BusinessEnum.TmpControlModel.Heating) &&
                             (Convert.ToInt32(nowTmpValue) >= Convert.ToInt32(targetTmp)))
                    {
                        deviceControlStatus = BusinessEnum.DeviceControlStatus.Close;
                    }
                    else
                    {
                        DateTime dtmNowTime = DateTime.Now;

                        TimeSpan ts1 = new TimeSpan(deviceModel.LastOpenTime.Ticks);
                        TimeSpan ts2 = new TimeSpan(dtmNowTime.Ticks);
                        TimeSpan ts  = ts1.Subtract(ts2).Duration();
                        if (ts.Minutes > deviceModel.OpenMaxTime)
                        {
                            // 距离上次压缩机打开时间超过规定的最长时间
                            deviceControlStatus = BusinessEnum.DeviceControlStatus.Close;
                        }
                    }
                }
            }
            catch
            {
                deviceControlStatus = BusinessEnum.DeviceControlStatus.Keep;
            }

            return(deviceControlStatus);
        }