Ejemplo n.º 1
0
 /// <summary>
 /// 拷贝构造函数
 /// </summary>
 /// <param name="other"></param>
 public AgingParameter(AgingParameter other)
 {
     m_PumpType         = other.m_PumpType;
     m_Rate             = other.m_Rate;
     m_Volume           = other.m_Volume;
     m_ChargeTime       = other.m_ChargeTime;
     m_DischargeTime    = other.m_DischargeTime;
     m_RechargeTime     = other.m_RechargeTime;
     m_OcclusionLevel   = other.m_OcclusionLevel;
     m_C9OcclusionLevel = other.m_C9OcclusionLevel;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// C9专用充电命令
        /// </summary>
        /// <param name="rate"></param>
        /// <param name="volume"></param>
        /// <param name="level">C9压力</param>
        /// <param name="remoteSocket"></param>
        /// <param name="func"></param>
        /// <param name="timeoutFunc"></param>
        /// <param name="channel"></param>
        public void SendCmdCharge(decimal rate, decimal volume, C9OcclusionLevel level, AsyncSocketUserToken remoteSocket, EventHandler <EventArgs> func, EventHandler <EventArgs> timeoutFunc, byte channel = 0xFF)
        {
            CmdChargeC9 cmd = new CmdChargeC9();

            cmd.Channel = channel;
            cmd.SetRate(rate);
            cmd.SetVolume(volume);
            cmd.SetOcclusionLevel(level);
            cmd.RemoteSocket = remoteSocket;
            long ip = ControllerManager.GetLongIPFromSocket(remoteSocket);

            AddCommand(ip, cmd, func, timeoutFunc);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pumpType"></param>
 /// <param name="rate"></param>
 /// <param name="volume"></param>
 /// <param name="chargeTime"></param>
 /// <param name="dischargeTime"></param>
 /// <param name="rechargeTime"></param>
 /// <param name="oclusionLevel"></param>
 /// <param name="c9OclusionLevel"></param>
 public AgingParameter(string pumpType,
                       decimal rate,
                       decimal volume,
                       decimal chargeTime,
                       decimal dischargeTime,
                       decimal rechargeTime,
                       OcclusionLevel oclusionLevel,
                       C9OcclusionLevel c9OclusionLevel = C9OcclusionLevel.Level3
                       )
 {
     m_PumpType         = pumpType;
     m_Rate             = rate;
     m_Volume           = volume;
     m_ChargeTime       = chargeTime;
     m_DischargeTime    = dischargeTime;
     m_RechargeTime     = rechargeTime;
     m_OcclusionLevel   = oclusionLevel;
     m_C9OcclusionLevel = c9OclusionLevel;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 设置C9压力
 /// </summary>
 /// <param name="level"></param>
 public void SetOcclusionLevel(C9OcclusionLevel level)
 {
     m_C9OcclusionLevel = level;
 }
Ejemplo n.º 5
0
 private bool LoadParameter(string path)
 {
     ParameterManager.Instance().Clear();
     if (!File.Exists(path))
     {
         Logger.Instance().ErrorFormat("老化参数配置文件不存在 path={0}", path);
         return(false);
     }
     try
     {
         decimal[] outValue      = new decimal[5];
         string    factorString  = string.Empty;
         char[]    separatorLine = new char[2] {
             (char)0x0D, (char)0x0A
         };
         char[] separator = new char[2] {
             '\t', ' '
         };
         StreamReader reader = new StreamReader(path);
         if (reader != null)
         {
             factorString = reader.ReadToEnd();
             reader.Close();
             string[] factors = factorString.Split(separatorLine, StringSplitOptions.RemoveEmptyEntries);
             foreach (string s in factors)
             {
                 #region
                 string[]         factor  = s.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                 OcclusionLevel   level   = OcclusionLevel.H;
                 C9OcclusionLevel c9Level = C9OcclusionLevel.Level3;
                 if (factor.Length != 7)
                 {
                     continue;
                 }
                 if (decimal.TryParse(factor[1], out outValue[0]) &&
                     decimal.TryParse(factor[2], out outValue[1]) &&
                     decimal.TryParse(factor[3], out outValue[2]) &&
                     decimal.TryParse(factor[4], out outValue[3]) &&
                     decimal.TryParse(factor[5], out outValue[4])
                     )
                 {
                     if (Enum.IsDefined(typeof(OcclusionLevel), factor[6]))
                     {
                         level = (OcclusionLevel)Enum.Parse(typeof(OcclusionLevel), factor[6]);
                     }
                     else if (Enum.IsDefined(typeof(C9OcclusionLevel), factor[6]))
                     {
                         c9Level = (C9OcclusionLevel)Enum.Parse(typeof(C9OcclusionLevel), factor[6]);
                     }
                     else
                     {
                         break;
                     }
                     //如果转换成功,就新建一个DefaultParameter对象
                     ParameterManager.Instance().Add(new AgingParameter(factor[0], outValue[0], outValue[1], outValue[2], outValue[3], outValue[4], level, c9Level));
                     continue;
                 }
                 #endregion
             }
         }
         else
         {
             Logger.Instance().Error("LoadParameter()读文件错误");
         }
     }
     catch (Exception e)
     {
         Logger.Instance().ErrorFormat("LoadParameter()读文件错误,Message={0}", e.Message);
     }
     return(true);
 }
Ejemplo n.º 6
0
        private void OnSave(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbRate.Text.Trim()) ||
                string.IsNullOrEmpty(tbVolume.Text.Trim()) ||
                string.IsNullOrEmpty(tbCharge.Text.Trim()) ||
                string.IsNullOrEmpty(tbRecharge.Text.Trim()) ||
                cmPumpType.SelectedIndex < 0 ||
                cmOcclusionLevel.SelectedIndex < 0
                )
            {
                MessageBox.Show("请将参数填写完整");
                return;
            }
            string  szCustomPid     = cmPumpType.Items[cmPumpType.SelectedIndex].ToString();
            string  szPressureLevel = cmOcclusionLevel.Items[cmOcclusionLevel.SelectedIndex].ToString();
            decimal rate            = Convert.ToDecimal(float.Parse(tbRate.Text).ToString("F1"));
            decimal volume          = Convert.ToDecimal(float.Parse(tbVolume.Text).ToString("F1"));
            decimal charge          = Convert.ToDecimal(tbCharge.Text);

            CustomProductID  cid     = ProductIDConvertor.Name2CustomProductID(szCustomPid);
            OcclusionLevel   level   = OcclusionLevel.H;
            C9OcclusionLevel c9Level = C9OcclusionLevel.Level3;

            if (cid == CustomProductID.GrasebyC9)
            {
                if (Enum.IsDefined(typeof(C9OcclusionLevel), szPressureLevel))
                {
                    c9Level = (C9OcclusionLevel)Enum.Parse(typeof(C9OcclusionLevel), szPressureLevel);
                }
                else
                {
                    Logger.Instance().ErrorFormat("Configuration::OnSave()->压力转换出错,C9OcclusionLevel={0}", szPressureLevel);
                }
            }
            else
            {
                if (Enum.IsDefined(typeof(OcclusionLevel), szPressureLevel))
                {
                    level = (OcclusionLevel)Enum.Parse(typeof(OcclusionLevel), szPressureLevel);
                }
                else
                {
                    Logger.Instance().ErrorFormat("Configuration::OnSave()->压力转换出错,OcclusionLevel={0}", szPressureLevel);
                }
            }

            decimal        discharge     = 0;
            decimal        recharge      = Convert.ToDecimal(tbRecharge.Text);
            Hashtable      dockParameter = new Hashtable();
            AgingParameter para          = new AgingParameter(szCustomPid,
                                                              rate,
                                                              volume,
                                                              charge,
                                                              discharge,
                                                              recharge,
                                                              level,
                                                              c9Level);

            for (int i = 0; i < otherDockCheckBoxGrid.Children.Count; i++)
            {
                if (otherDockCheckBoxGrid.Children[i] is CheckBox)
                {
                    CheckBox box = otherDockCheckBoxGrid.Children[i] as CheckBox;
                    if (box.IsChecked.HasValue)
                    {
                        if (box.IsChecked == true)
                        {
                            dockParameter.Add((int)box.Tag, new AgingParameter(para));   //这里需要拷贝一份新的参数
                        }
                    }
                }
            }
            if (OnSaveConfigration != null)
            {
                OnSaveConfigration(this, new ConfigrationArgs(dockParameter));
            }
            this.DialogResult = true;
        }