Beispiel #1
0
        public static FullScreenConfigBO getFullScreenConfigBO()
        {
            FullScreenConfigBO fBO = new FullScreenConfigBO();
            bool isImg             = InIHelper.ReadConfig <bool>(fBO.key, "isImg");

            fBO.isImg = isImg;
            string backgroundColor = InIHelper.ReadConfig <string>(fBO.key, "backgroundColor");

            if (backgroundColor != null && backgroundColor != "")
            {
                fBO.backgroundColor = ColorTranslator.FromHtml(backgroundColor);
            }
            string backgroundImg = InIHelper.ReadConfig <string>(fBO.key, "backgroundImg");

            if (File.Exists(backgroundImg))
            {
                fBO.backgroundImg = backgroundImg;
            }
            string transparency = InIHelper.ReadConfig <string>(fBO.key, "transparency");

            if (transparency != null && transparency != "")
            {
                fBO.transparency = Int32.Parse(transparency);
            }
            fBO.offTaskManager = InIHelper.ReadConfig <bool>(fBO.key, "offTaskManager");
            return(fBO);
        }
        /// <summary>
        /// 删除仪器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void DeleteBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            //删除仪器前需选中一个仪器
            if (Instruments.SelectedItem == null)
            {
                await this.MsgBox("Please select a instrument.");
            }
            else
            {
                //弹出删除警告
                var message = "All information related to the selected item will be permanently deleted.\r\n" +
                              "Please click 'DELETE' to confirm.";
                var result = await this.MsgBox(message, "DELETE", "CANCEL");

                if ((bool)result)
                {
                    //从全局变量中移除所删除的仪器
                    var item = (InstrumentModel)Instruments.SelectedItem;
                    //从配置文件中删除对应仪器
                    SystemSettings.InstrumentsList.Remove(item);
                    InIHelper.FileName = SystemSettings.InstrumentIniFile;
                    InIHelper.DeleteSection(item.Name);
                }
            }
        }
Beispiel #3
0
 public static bool setOperatingConfigBO(OperatingConfigBO oBO)
 {
     try
     {
         InIHelper.WriteConfig(oBO.key, "isRecording", oBO.isRecording.ToString());
         InIHelper.WriteConfig(oBO.key, "isFrequency", oBO.isFrequency.ToString());
         InIHelper.WriteConfig(oBO.key, "frequency", oBO.frequency.ToString());
         InIHelper.WriteConfig(oBO.key, "isFinalProcedure", oBO.isFinalProcedure.ToString());
         InIHelper.WriteConfig(oBO.key, "finalProcedure", oBO.finalProcedure);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #4
0
 public static bool setFullScreenConfigBO(FullScreenConfigBO fBO)
 {
     try
     {
         InIHelper.WriteConfig(fBO.key, "isImg", fBO.isImg.ToString());
         InIHelper.WriteConfig(fBO.key, "backgroundColor", ColorTranslator.ToHtml(fBO.backgroundColor));
         InIHelper.WriteConfig(fBO.key, "backgroundImg", fBO.backgroundImg);
         InIHelper.WriteConfig(fBO.key, "transparency", fBO.transparency.ToString());
         InIHelper.WriteConfig(fBO.key, "offTaskManager", fBO.offTaskManager.ToString());
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public static bool setPasswordConfigBO(PasswordConfigBO pBO)
 {
     try
     {
         InIHelper.WriteConfig(pBO.key, "isDefaultPassword", pBO.isDefaultPassword.ToString());
         InIHelper.WriteConfig(pBO.key, "isPasswordPrompt", pBO.isPasswordPrompt.ToString());
         InIHelper.WriteConfig(pBO.key, "passwordPrompt", pBO.passwordPrompt);
         InIHelper.WriteConfig(pBO.key, "enterDirectly", pBO.enterDirectly.ToString());
         InIHelper.WriteConfig(pBO.key, "defaultPassword", DesHelper.Encode(pBO.defaultPassword));
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #6
0
        public static OperatingConfigBO getOperatingConfigBO()
        {
            OperatingConfigBO oBO = new OperatingConfigBO();

            oBO.isRecording = InIHelper.ReadConfig <bool>(oBO.key, "isRecording");
            oBO.isFrequency = InIHelper.ReadConfig <bool>(oBO.key, "isFrequency");
            int frequency = InIHelper.ReadConfig <int>(oBO.key, "frequency");

            oBO.frequency        = frequency == 0 ? 1 : frequency;
            oBO.isFinalProcedure = InIHelper.ReadConfig <bool>(oBO.key, "isFinalProcedure");
            string finalProcedure = InIHelper.ReadConfig <string>(oBO.key, "finalProcedure");

            if (finalProcedure != null && finalProcedure != "")
            {
                oBO.finalProcedure = finalProcedure;
            }
            return(oBO);
        }
        /// <summary>
        /// 保存仪器配置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            //try
            //{
            //    var instr = ((InstrumentModel)Instruments.SelectedItem);

            //    var tt = new EVB1_QsfpDD(instr);

            //    tt.Open();

            //    tt.Write(0xA0, 0x7F, new[] { (byte)0x00 });

            //    var data= tt.Read(0xa0, 0x80, 128);

            //    tt.Close();


            //}
            //catch (Exception exp)
            //{

            //}

            try
            {
                foreach (InstrumentModel instr in Instruments.Items)
                {
                    var jSetting = new JsonSerializerSettings()
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    };
                    var value = JsonConvert.SerializeObject(instr.Config, jSetting);
                    InIHelper.FileName = SystemSettings.InstrumentIniFile;
                    InIHelper.Write(instr.Name, "Type", instr.CommnunicationType.ToString());
                    InIHelper.Write(instr.Name, "Config", value);
                }
                SystemSettings.SnackbarMessageQueue.Enqueue("All COnfigurations saved sucessful");
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        public static PasswordConfigBO getPasswordConfigBO()
        {
            PasswordConfigBO tmp = new PasswordConfigBO();

            tmp.isDefaultPassword = InIHelper.ReadConfig <bool>(tmp.key, "isDefaultPassword");
            string defaultPassword = InIHelper.ReadConfig <string>(tmp.key, "defaultPassword");

            if (defaultPassword != null && defaultPassword != "")
            {
                tmp.defaultPassword = DesHelper.Decode(defaultPassword);
            }
            tmp.isPasswordPrompt = InIHelper.ReadConfig <bool>(tmp.key, "isPasswordPrompt");
            string passwordPrompt = InIHelper.ReadConfig <string>(tmp.key, "passwordPrompt");

            if (passwordPrompt != null && passwordPrompt != "")
            {
                tmp.passwordPrompt = passwordPrompt;
            }
            tmp.enterDirectly = InIHelper.ReadConfig <bool>(tmp.key, "enterDirectly");
            return(tmp);
        }
Beispiel #9
0
        /// <summary>
        /// 从仪器配置文件中读取所有仪器配置
        /// </summary>
        private void LoadInstruments()
        {
            //SerialPort,
            //GPIB,
            //TCP,
            //USB,
            //UDP,
            object obj = null;

            InIHelper.FileName = SystemSettings.InstrumentIniFile;
            //Json转换条件,忽略空值属性
            var jsSetting = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            };

            //读取所有设备字段信息-设备名称
            foreach (var item in InIHelper.ReadSections())
            {
                var cfg     = InIHelper.Read(item, "Config", null); //读取配置
                var typeStr = InIHelper.Read(item, "Type", null);   //读取通信方式
                if (Enum.IsDefined(typeof(CommunicationType), typeStr))
                {
                    var type = (CommunicationType)Enum.Parse(typeof(CommunicationType), typeStr, true);//格式化通讯方式为enum
                    //根据不同通讯方式创建不同仪器实例信息
                    switch (type)
                    {
                    case CommunicationType.UDP:
                        obj = JsonConvert.DeserializeObject <UdpCfgModel>(cfg, jsSetting);
                        break;

                    case CommunicationType.TCP:
                        obj = JsonConvert.DeserializeObject <TcpIpCfgModel>(cfg, jsSetting);
                        break;

                    case CommunicationType.SerialPort:
                        obj = JsonConvert.DeserializeObject <SerialPortCfgModel>(cfg, jsSetting);
                        break;

                    case CommunicationType.GPIB:
                        obj = JsonConvert.DeserializeObject <GPIBCfgModel>(cfg, jsSetting);
                        break;

                    case CommunicationType.USB:
                        obj = JsonConvert.DeserializeObject <USBCfgModel>(cfg, jsSetting);
                        break;

                    default:
                        break;
                    }
                    var instr = new InstrumentModel()
                    {
                        Name               = item,
                        Config             = obj,
                        CommnunicationType = type,
                        CommReference      = CommunicationBase.CreateCommunication(type)
                    };
                    //添加至系统全局变量中
                    SystemSettings.InstrumentsList.Add(instr);
                }
            }
        }