コード例 #1
0
        public ScadaDataProvider()
        {
            Interop         = WCFInteropSingleton.GetInstance();
            _expreimentVars = Interop.ExperimentVars;
            foreach (KeyValuePair <string, Dictionary <string, object> > experiment in _expreimentVars)
            {
                object o = FactoryDynamicObjectExperimentBinding.CreateDynamicObjectExperimentBinding(experiment.Key,
                                                                                                      experiment.Value);
                if (o == null)
                {
                    break;
                }
                ls.Add(o);
                Type           _type = o.GetType();
                PropertyInfo[] prop  = _type.GetProperties();

                foreach (KeyValuePair <string, object> variable in experiment.Value)
                {
                    for (int i = 0; i < prop.Length; i++)
                    {
                        if (prop[i].Name == variable.Key)
                        {
                            prop[i].SetValue(o, variable.Value, null);
                            break;
                        }
                    }
                }
            }
            timer            = new Timer(OnTimming, this, 100, 100);
            refreshFrequency = 100;
            //var asd = new {Name="P00", Value=true};
        }
コード例 #2
0
        private static void OnTiming(object state)
        {
            WCFInteropSingleton container = state as WCFInteropSingleton;

            Variable[] vars;
            try
            {
                lock (lckObj)
                {
                    foreach (KeyValuePair <string, Dictionary <string, object> > pair in container.experimentVars)
                    {
                        vars = container.client.GetVariableExperiment(pair.Key);
                        if (vars.Length > 0)
                        {
                            for (int i = 0; i < vars.Length; i++)
                            {
                                pair.Value[vars[i].Name] = vars[i].Value;
                            }
                        }
                    }
                    for (int i = 0; i < container.scripts.Count; i++)
                    {
                        container.scripts[i].Execute(ref container.experimentVars);
                    }
                }
            }
            catch (Exception e)
            {
                container.Login();
            }
            container.timer.Change(container.RefreshFrequency, Timeout.Infinite);
        }
コード例 #3
0
 public ScadaDataSource(string experimentName)
 {
     this.experimentName = experimentName;
     propertyChange      = new ScadaDataPropertyChange();
     Interop             = WCFInteropSingleton.GetInstance();
     timer = new Timer(OnTiming, this, Timeout.Infinite, Timeout.Infinite);
     // Loaded += Load;
 }
コード例 #4
0
 public static WCFInteropSingleton GetInstance()
 {
     lock (lckObj)
     {
         if (obj == null)
         {
             obj = new WCFInteropSingleton();
         }
         return(obj);
     }
 }
コード例 #5
0
        private static void OnTiming(object state)
        {
            ScadaDataSource     container = (state as ScadaDataSource);
            WCFInteropSingleton _Interop  = container.Interop;

            Dictionary <string, object> variables;

            try
            {
                variables = _Interop.GetVariableExperiment(container.experimentName);
                if (variables.Count > 0)
                {
                    container.propertyChange.Receive(variables);
                    //container.Transmit(variables);
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show("Se jodio OnTiming");
                //_Interop.Login(container.LogUser, container.LogPassword);
            }
            container.timer.Change(container.RefreshFrequency, Timeout.Infinite);
        }
コード例 #6
0
        private static void OnTimming(object state)
        {
            ScadaDataProvider   container = (state as ScadaDataProvider);
            WCFInteropSingleton _Interop  = container.Interop;


            try
            {
                var experiment = _Interop.ExperimentVars;
                if (experiment.Count > 0)
                {
                    for (int i = 0; i < container.ls.Count; i++)
                    {
                        Type           _type = container.ls[i].GetType();
                        PropertyInfo[] prop  = _type.GetProperties();
                        foreach (KeyValuePair <string, object> variable in experiment[_type.Name])
                        {
                            for (int j = 0; j < prop.Length; j++)
                            {
                                if (prop[j].Name == variable.Key)
                                {
                                    prop[j].SetValue(container.ls[i], variable.Value, null);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show("Se jodio OnTiming");
                //_Interop.Login(container.LogUser, container.LogPassword);
            }
            container.timer.Change(container.RefreshFrequency, Timeout.Infinite);
        }
コード例 #7
0
 public ScadaDataFeedBack()
 {
     Interop = WCFInteropSingleton.GetInstance();
     // Loaded += Load;
 }
コード例 #8
0
 public ScadaDataSource()
 {
     Interop = WCFInteropSingleton.GetInstance();
     timer   = new Timer(OnTiming, this, Timeout.Infinite, Timeout.Infinite);
     //            Loaded += Load;
 }