Esempio n. 1
0
        public TelemetryValue TelemetryValueByName(string name)
        {
            TelemetryValue tv;

            switch (name)
            {
            default:
                object       data;
                Type         eleDataType = typeof(DCSData);
                PropertyInfo propertyInfo;
                FieldInfo    fieldInfo = eleDataType.GetField(name);
                if (fieldInfo != null)
                {
                    data = fieldInfo.GetValue(telemetryData);
                }
                else if ((propertyInfo = eleDataType.GetProperty(name)) != null)
                {
                    data = propertyInfo.GetValue(telemetryData, null);
                }
                else
                {
                    throw new UnknownTelemetryValueException(name);
                }
                tv = new DCSTelemetryValue(name, data);
                object value = tv.Value;
                if (value == null)
                {
                    throw new UnknownTelemetryValueException(name);
                }

                break;
            }

            return(tv);
        }
Esempio n. 2
0
        public TelemetryValue TelemetryValueByName(string name)
        {
            TelemetryValue tv;

            switch (name)
            {
            case "roll":
                tv = new DCSTelemetryValue("roll", Roll);
                break;

            case "pitch":
                tv = new DCSTelemetryValue("pitch", Pitch);
                break;

            case "yaw":
                tv = new DCSTelemetryValue("yaw", Yaw);
                break;

            case "rollrate":
                tv = new DCSTelemetryValue("rollrate", RollRate);
                break;

            case "pitchrate":
                tv = new DCSTelemetryValue("pitchrate", PitchRate);
                break;

            case "yawrate":
                tv = new DCSTelemetryValue("yawrate", YawRate);
                break;

            case "rollroc":
                tv = new DCSTelemetryValue("rollroc", RollRoc);
                break;

            case "pitchroc":
                tv = new DCSTelemetryValue("pitchroc", PitchRoc);
                break;

            case "yawroc":
                tv = new DCSTelemetryValue("yawroc", YawRoc);
                break;

            default:
                object       data;
                Type         eleDataType = typeof(DCSData);
                PropertyInfo propertyInfo;
                FieldInfo    fieldInfo = eleDataType.GetField(name);
                if (fieldInfo != null)
                {
                    data = fieldInfo.GetValue(telemetryData);
                }
                else if ((propertyInfo = eleDataType.GetProperty(name)) != null)
                {
                    data = propertyInfo.GetValue(telemetryData, null);
                }
                else
                {
                    throw new UnknownTelemetryValueException(name);
                }
                tv = new DCSTelemetryValue(name, data);
                object value = tv.Value;
                if (value == null)
                {
                    throw new UnknownTelemetryValueException(name);
                }

                break;
            }

            return(tv);
        }