예제 #1
0
            public static double GetNumericValue(IStruct structure, string name)
            {
                if (structure == null)
                {
                    throw new ArgumentNullException("structure");
                }

                ISymbol symbol = structure.Child(name);

                if (symbol == null)
                {
                    throw new InvalidOperationException("Could not find the property " + name + " in structure " + structure.Name);
                }

                INumericProperty property = symbol as INumericProperty;

                if (property == null)
                {
                    throw new InvalidOperationException("Symbol " + symbol.Name + " type " + symbol.GetType().FullName + " is not the expected " + typeof(INumericProperty).FullName);
                }

                double result = property.Value.GetValueOrDefault();

                return(result);
            }
예제 #2
0
            public static INumericProperty GetNumeric(IPage page, string name)
            {
                IProperty        property = GetProperty(page, name);
                INumericProperty result   = property as INumericProperty;

                if (result == null)
                {
                    throw new InvalidOperationException("Property " + property.Name + " type " + property.GetType().FullName + " is not the expected " + typeof(INumericProperty).FullName);
                }
                return(result);
            }
예제 #3
0
        private static void DemoCode(IEditorPlugIn plugIn, IPage page)
        {
            IList <ISymbol> deviceNodes = plugIn.Symbol.SelectSymbols("//Device[Properties[@Name='ModelNo' and @Value='Pump']]");

            IStruct temperatureSrut    = Util.Properties.GetStruct(page, "Temperature");
            double  temperatureNominal = Util.Properties.GetNumericValue(temperatureSrut, "Nominal");
            double  temperatureValue   = Util.Properties.GetNumericValue(temperatureSrut, "Value");
            double  temperatureMin     = Util.Properties.GetNumericValue(temperatureSrut, "LowerLimit");
            double  temperatureMax     = Util.Properties.GetNumericValue(temperatureSrut, "UpperLimit");

            bool ready = Util.Properties.GetBoolValue(page, "Ready");

            foreach (ISymbol symbol in deviceNodes)
            {
                ISymbol symbolFlowStruct = symbol.Child("Flow");
                if (symbolFlowStruct != null)
                {
                    IStruct structure = symbolFlowStruct as IStruct;
                    if (structure == null)
                    {
                        string errText = "Symbol " + symbolFlowStruct.Name + " must always be of type " + typeof(IStruct).FullName + ", but is " + symbolFlowStruct.GetType().FullName;
                        throw new InvalidCastException(errText);
                    }

                    ISymbol symbolFlow = structure.Child("Value");
                    if (symbolFlow == null)
                    {
                        throw new InvalidOperationException("Could not find the property Value in structure " + symbolFlowStruct.Name);
                    }

                    double flow = (symbolFlow as INumericProperty).Value.GetValueOrDefault();
                    //              Pump_Name            Flow                          Value
                    Trace.WriteLine(symbol.Name + "." + symbolFlowStruct.Name + "." + plugIn.Symbol.Name + " = " + flow.ToString());
                }

                ISymbol symbolReady = symbol.Child(SymbolName.Ready);
                if (symbolReady != null)
                {
                    INumericProperty propertyReady = symbolReady as INumericProperty;
                    if (propertyReady != null)
                    {
                        ready = Util.GetBool(propertyReady);
                        Trace.WriteLine(propertyReady.Name + " = " + ready.ToString());
                        if (propertyReady.Writeable)
                        {
                            //              Pump_Name           Ready
                            Trace.WriteLine(symbol.Name + "." + propertyReady.Name + " is Writable");
                        }
                    }
                }
            }
        }
예제 #4
0
        public NumericEditor(INumericProperty property)
        {
            InitializeComponent();

            ((ISupportInitialize)numericUpDown1).BeginInit();
            numericUpDown1.Maximum       = property.Max;
            numericUpDown1.Minimum       = property.Min;
            numericUpDown1.Value         = property.Min;
            numericUpDown1.DecimalPlaces = property.DecimalPlaces;
            numericUpDown1.Increment     = property.Step;
            ((ISupportInitialize)numericUpDown1).EndInit();

            numericUpDown1.ValueChanged += numericUpDown1_ValueChanged;
        }
예제 #5
0
 protected override void InitializeProperties()
 {
     _agent = InitProperty <Property>(PropName) as INumericProperty;
 }
예제 #6
0
 public static bool GetBool(INumericProperty property)
 {
     return(property.Value.GetValueOrDefault() != 0);
 }
예제 #7
0
            public static bool GetBoolValue(IPage page, string name)
            {
                INumericProperty property = Properties.GetNumeric(page, name);

                return(property.Value.GetValueOrDefault() != 0);
            }
예제 #8
0
            public static double GetNumericValue(IPage page, string name)
            {
                INumericProperty property = Properties.GetNumeric(page, name);

                return(property.Value.GetValueOrDefault());
            }