Esempio n. 1
0
 private void ExtractDCSBIOSOutputsInFormula()
 {
     try
     {
         var found    = false;
         var controls = DCSBIOSControlLocator.GetControls();
         foreach (var dcsbiosControl in controls)
         {
             if (_formula.Contains(dcsbiosControl.identifier))
             {
                 //   Console.WriteLine("Variable " + dcsbiosControl.identifier + " set to 0");
                 _variables.Add(dcsbiosControl.identifier, 0);
                 var dcsbiosOutput = DCSBIOSControlLocator.GetDCSBIOSOutput(dcsbiosControl.identifier);
                 _dcsbiosOutputs.Add(dcsbiosOutput);
                 DCSBIOSProtocolParser.RegisterAddressToBroadCast(dcsbiosOutput.Address);
                 found = true;
             }
         }
         if (!found)
         {
             throw new Exception("Could not find any DCS-BIOS Controls in formula expression.");
         }
         //_expression = new Expression(_formula);
     }
     catch (Exception ex)
     {
         Common.LogError(1955594, ex, "ExtractDCSBIOSOutputsInFormula() function");
         throw;
     }
 }
        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;
 }
Esempio n. 4
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;
            }
            }
        }
        public static DCSBIOSOutput GetUpdateCounter()
        {
            var counter = DCSBIOSControlLocator.GetDCSBIOSOutput("_UPDATE_COUNTER");

            return(counter);
        }