Beispiel #1
0
        /// <summary>
        /// 确认
        /// </summary>
        public void ConfirmClick()
        {
            switch (_fanSetModel)
            {
            case 1:
                _main.EcViewCollec[_index].FanSet      = "自动调节";
                _main.EcViewCollec[_index].FanSetModel = 1;
                _iFanDutyModify.SetFanduty(_index + 1, 0, true);
                _main.EcViewCollec[_index].UpdateFlag = true;

                //关闭窗口
                TryClose();
                break;

            case 2:
                _main.EcViewCollec[_index].FanSet      = "手动调节";
                _main.EcViewCollec[_index].FanSetModel = 2;
                _main.EcViewCollec[_index].FanDuty     = _fanDuty;
                _main.EcViewCollec[_index].FanDutyStr  = _fanDuty + "%";
                _iFanDutyModify.SetFanduty(_index + 1, (int)(_fanDuty * 2.55m), false);
                _main.EcViewCollec[_index].UpdateFlag = true;

                //关闭窗口
                TryClose();
                break;

            case 3:
                _main.EcViewCollec[_index].FanSet      = "智能调节";
                _main.EcViewCollec[_index].FanSetModel = 3;
                if (string.IsNullOrEmpty(_filePath))
                {
                    MessageBox.Show("请选择配置文件", "提示信息", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    _main.EcViewCollec[_index].UpdateFlag = true;
                    MessageBox.Show("智能调节将在程序关闭后启用", "提示信息", MessageBoxButton.OK, MessageBoxImage.Information);

                    //关闭窗口
                    TryClose();
                }
                break;
            }
        }
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void _initECData(EcViewBinding ecviewData)
        {
            //判断配置文件是否存在
            if (System.IO.File.Exists(_currentDirectory + "ecview.cfg"))
            {
                var configParaList = _iFanDutyModify.ReadCfgFile(_currentDirectory + "ecview.cfg");
                //风扇转速与温度信息
                Debug.Assert(configParaList != null, "configParaList != null");
                for (var i = 0; i < configParaList.Count; i++)
                {
                    var ecData = _iFanDutyModify.GetTempFanDuty(i + 1);
                    _nbModel         = configParaList[0].NbModel;
                    _ecVersion       = configParaList[0].EcVersion;
                    ecviewData.FanNo = i + 1;
                    foreach (var configPara in configParaList.Where(configPara => ecviewData.FanNo == configPara.FanNo))
                    {
                        ecviewData.FanSetModel = configPara.SetMode;
                        ecviewData.FanSet      = configPara.FanSet;
                        switch (configPara.SetMode)
                        {
                        case 1:
                            //若上次配置为自动调节,设置风扇自动调节
                            ecData = _iFanDutyModify.SetFanduty(configPara.FanNo, 0, true);
                            break;

                        case 2:
                            //若为上次配置手动调节,设置风扇转速
                            ecData = _iFanDutyModify.SetFanduty(configPara.FanNo, (int)(configPara.FanDuty * 2.55m), false);
                            break;
                        }
                    }
                    _cpuRemote            = ecData[0] + "℃";
                    _cpuLocal             = ecData[1] + "℃";
                    ecviewData.UpdateFlag = false;
                    ecviewData.FanDutyStr = ecData[2] + "%";
                    ecviewData.FanDuty    = ecData[2];
                    _ecDataList.Add(ecviewData);
                }
            }
            else
            {
                var searcherBaseBoard = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_BaseBoard");
                //模具型号
                _nbModel = "当前模具型号为:";
                foreach (var baseBoard in searcherBaseBoard.Get())
                {
                    _nbModel += Convert.ToString((baseBoard)["Product"]);
                }
                //EC版本
                _ecVersion  = "当前EC版本为:1.";
                _ecVersion += _iFanDutyModify.GetEcVersion();
                //风扇数量
                _fanCount = _iFanDutyModify.GetFanCount();
                if (_fanCount > 4)
                {
                    _fanCount = 0;
                }
                if (_fanCount == 0)
                {
                    _fanCount = 1;
                }
                //风扇转速与温度信息
                for (var i = 0; i < _fanCount; i++)
                {
                    var ecData = _iFanDutyModify.GetTempFanDuty(i + 1);
                    _cpuRemote             = ecData[0] + "℃";
                    _cpuLocal              = ecData[1] + "℃";
                    ecviewData.FanDutyStr  = ecData[2] + "%";
                    ecviewData.FanDuty     = ecData[2];
                    ecviewData.FanNo       = i + 1;
                    ecviewData.FanSet      = "未设置";
                    ecviewData.FanSetModel = 0;
                    ecviewData.UpdateFlag  = false;
                    _ecDataList.Add(ecviewData);
                }
            }
        }