예제 #1
0
        public void ImportString(string str)
        {
            //DCSBiosOutput{AAP_EGIPWR|Equals|0}
            var value = str;

            if (string.IsNullOrEmpty(str))
            {
                throw new Exception("DCSBiosOutput cannot import null string.");
            }
            if (!str.StartsWith("DCSBiosOutput{") || !str.EndsWith("}"))
            {
                throw new Exception("DCSBiosOutput cannot import string : " + str);
            }
            value = value.Replace("DCSBiosOutput{", "").Replace("}", "");
            //AAP_EGIPWR|Equals|0
            var entries = value.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            _controlId = entries[0];
            var dcsBIOSControl = DCSBIOSControlLocator.GetControl(_controlId);

            Consume(dcsBIOSControl);
            _dcsBiosOutputComparison = (DCSBiosOutputComparison)Enum.Parse(typeof(DCSBiosOutputComparison), entries[1]);
            if (DCSBiosOutputType == DCSBiosOutputType.INTEGER_TYPE)
            {
                _specifiedValueInt = (uint)int.Parse(entries[2]);
            }
            else if (DCSBiosOutputType == DCSBiosOutputType.STRING_TYPE)
            {
                _specifiedValueString = entries[2];
            }
        }
 public static DCSBIOSInput GetDCSBIOSInput(string controlId)
 {
     var result = new DCSBIOSInput();
     var control = DCSBIOSControlLocator.GetControl(controlId);
     result.Consume(control);
     return result;
 }
예제 #3
0
        public void ImportString(string str)
        {
            //DCSBIOSInput{AAP_EGIPWR|FIXED_STEP|INC}
            //DCSBIOSInput{AAP_EGIPWR|SET_STATE|65535}
            //DCSBIOSInput{AAP_EGIPWR|ACTION|TOGGLE}
            var value = str;

            if (string.IsNullOrEmpty(str))
            {
                throw new Exception("DCSBIOSInput cannot import null string.");
            }
            if (!str.StartsWith("DCSBIOSInput{") || !str.EndsWith("}"))
            {
                throw new Exception("DCSBIOSInput cannot import string : " + str);
            }
            value = value.Substring(value.IndexOf("{", StringComparison.InvariantCulture) + 1);
            //AAP_EGIPWR|FIXED_STEP|INC}
            //AAP_EGIPWR|SET_STATE|65535}
            //AAP_EGIPWR|ACTION|TOGGLE}
            value = value.Substring(0, value.Length - 1);
            //AAP_EGIPWR|FIXED_STEP|INC
            //AAP_EGIPWR|SET_STATE|65535
            //AAP_EGIPWR|ACTION|TOGGLE
            var entries = value.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            _controlId = entries[0];
            var dcsBIOSControl = DCSBIOSControlLocator.GetControl(_controlId);

            Consume(dcsBIOSControl);

            switch (entries[1])
            {
            case "FIXED_STEP":
            {
                foreach (var dcsbiosInputObject in _dcsbiosInputObjects)
                {
                    if (dcsbiosInputObject.Interface == DCSBIOSInputType.FIXED_STEP)
                    {
                        dcsbiosInputObject.SpecifiedFixedStepArgument = (DCSBIOSFixedStepInput)Enum.Parse(typeof(DCSBIOSFixedStepInput), entries[2]);
                        _selectedDCSBIOSInput = dcsbiosInputObject;
                        break;
                    }
                }
                break;
            }

            case "SET_STATE":
            {
                foreach (var dcsbiosInputObject in _dcsbiosInputObjects)
                {
                    if (dcsbiosInputObject.Interface == DCSBIOSInputType.SET_STATE)
                    {
                        dcsbiosInputObject.SpecifiedSetStateArgument = uint.Parse(entries[2]);
                        _selectedDCSBIOSInput = dcsbiosInputObject;
                        break;
                    }
                }
                break;
            }

            case "ACTION":
            {
                foreach (var dcsbiosInputObject in _dcsbiosInputObjects)
                {
                    if (dcsbiosInputObject.Interface == DCSBIOSInputType.ACTION)
                    {
                        dcsbiosInputObject.SpecifiedActionArgument = entries[2];
                        _selectedDCSBIOSInput = dcsbiosInputObject;
                        break;
                    }
                }
                break;
            }

            case "VARIABLE_STEP":
            {
                foreach (var dcsbiosInputObject in _dcsbiosInputObjects)
                {
                    if (dcsbiosInputObject.Interface == DCSBIOSInputType.VARIABLE_STEP)
                    {
                        dcsbiosInputObject.SpecifiedVariableStepArgument = int.Parse(entries[2]);
                        _selectedDCSBIOSInput = dcsbiosInputObject;
                        break;
                    }
                }
                break;
            }
            }
        }