コード例 #1
0
        public SensorNode GetSensor(string source, string Identifier)
        {
            SensorNode result = null;

            if (source_id != source)
            {
                return(null);
            }
            foreach (SensorNodeBase node in children)
            {
                if (node.GetType() == typeof(SensorGroup))
                {
                    SensorGroup g = node as SensorGroup;
                    result = g.GetSensor(source, Identifier);
                }
                else
                {
                    SensorNode sens = node as SensorNode;
                    if (sens != null)
                    {
                        if (sens.identifier == Identifier)
                        {
                            result = sens;
                        }
                    }
                }
                if (result != null)
                {
                    break;
                }
            }
            return(result);
        }
コード例 #2
0
        public void Filter(UnitType f)
        {
            List <SensorNodeBase> remove = new List <SensorNodeBase>();

            foreach (SensorNodeBase node in children)
            {
                if (node != null && node.GetType() == typeof(SensorGroup))
                {
                    SensorGroup g = node as SensorGroup;
                    if (g != null)
                    {
                        g.Filter(f);
                        if (g.children.Count == 0)
                        {
                            remove.Add(node);
                        }
                    }
                }
                else if (node != null && (int)f != (int)node.unit)
                {
                    remove.Add(node);
                }
            }

            foreach (SensorNodeBase x in remove)
            {
                children.Remove(x);
            }
        }
コード例 #3
0
ファイル: DummyData.cs プロジェクト: sklemmer/plugin_sdk
        public SensorGroup read_sensors()
        {
            SensorGroup main_group = new SensorGroup();
            main_group.source_id = source;
            main_group.name = source;

            SensorNode node;

            node = new SensorNode();
            node.source_id = source;
            node.idx = 0;
            node.identifier = "hdkasdk";
            node.is_sensor = true;
            node.name = "Dummy Sensor 1";
            node.unit = (int)SensorNodeBase.UnitType.Number;
            node.range = (int)SensorNodeBase.Range.None;
            node.time_scale = (int)SensorNodeBase.TimeScale.None;
            node.sensor_value = rnd_number.Next(2000, 10000) / 100.0;
            main_group.children.Add(node);

            node = new SensorNode();
            node.source_id = source;
            node.idx = 0;
            node.identifier = "loz9324zld";
            node.is_sensor = true;
            node.name = "Dummy Sensor 2";
            node.unit = (int)SensorNodeBase.UnitType.Temperature;
            node.range = (int)SensorNodeBase.Range.None;
            node.time_scale = (int)SensorNodeBase.TimeScale.None;
            node.sensor_value = rnd_number.Next(5000, 7000) / 100.0;
            main_group.children.Add(node);

            return main_group;
        }
コード例 #4
0
ファイル: SensorNode.cs プロジェクト: DocHammoc/plugin_sdk
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'SensorNodeBase.GetSensor(string, string)'
        public SensorNode GetSensor(string source, string Identifier)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'SensorNodeBase.GetSensor(string, string)'
        {
            SensorNode result = null;

            if (source_id != source)
            {
                return(null);
            }
            foreach (SensorNodeBase node in children)
            {
                if (node.GetType() == typeof(SensorGroup))
                {
                    SensorGroup g = node as SensorGroup;
                    result = g.GetSensor(source, Identifier);
                }
                else
                {
                    SensorNode sens = node as SensorNode;
                    if (sens != null)
                    {
                        if (sens.identifier == Identifier)
                        {
                            result = sens;
                        }
                    }
                }
                if (result != null)
                {
                    break;
                }
            }
            return(result);
        }
コード例 #5
0
ファイル: SensorNode.cs プロジェクト: DocHammoc/plugin_sdk
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'SensorNodeBase.Filter(SensorNodeBase.UnitType)'
        public void Filter(UnitType f)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'SensorNodeBase.Filter(SensorNodeBase.UnitType)'
        {
            List <SensorNodeBase> remove = new List <SensorNodeBase>();

            foreach (SensorNodeBase node in children)
            {
                if (node != null && node.GetType() == typeof(SensorGroup))
                {
                    SensorGroup g = node as SensorGroup;
                    if (g != null)
                    {
                        g.Filter(f);
                        if (g.children.Count == 0)
                        {
                            remove.Add(node);
                        }
                    }
                }
                else if (node != null && (int)f != (int)node.unit)
                {
                    remove.Add(node);
                }
            }

            foreach (SensorNodeBase x in remove)
            {
                children.Remove(x);
            }
        }
コード例 #6
0
ファイル: OHM.cs プロジェクト: sklemmer/plugin_sdk
        public SensorGroup read_sensors()
        {
            if(read_error_count > 10)
            {
                TimeSpan diff = DateTime.Now - last_read;
                if (diff.TotalSeconds > 30)
                    read_error_count--; //allow one read out
                else
                    return null;
            }

            last_read = DateTime.Now;
            bool read_result = read();
            if (!read_result)
            {
                read_error_count++;
                return null;
            }
            if (sensors == null || sensors.Length == 0 || groups == null || groups.Length == 0)
            {
                read_error_count++;
                return null;
            }
            read_error_count = 0;

            SensorGroup main_group = new SensorGroup();
            main_group.source_id = source;
            main_group.name = source;
            foreach (OhmGroup g in groups)
            {
                if (g != null)
                {
                    SensorGroup newGroup = new SensorGroup();
                    newGroup.name = g.Name;
                    newGroup.source_id = source;
                    newGroup.children.AddRange(GetSensorsFromGroup(g.Identifier));
                    if (newGroup.children.Count > 0)
                    {
                        newGroup.children = newGroup.children.OrderBy(x => x.name).ToList();
                        main_group.children.Add(newGroup);
                    }
                }
            }
            return main_group;
        }
コード例 #7
0
        public void worker()
        {
            if (data_source == null)
            {
                return;
            }

            var sensors = data_source.read_sensors();

            if (sensors != null)
            {
                sensors.name       = this.info.Name;
                sensors.source_id  = this.unique_plugin_identifier;
                sensors.identifier = this.unique_plugin_identifier;
                sensor_data        = sensors;
                sensor_update      = true;
            }
        }
コード例 #8
0
 /// <summary>
 /// abort export plugin
 /// </summary>
 public void stop_instance()
 {
     data_source = null;
     sensor_data = null;
 }
コード例 #9
0
        public void worker()
        {
            if (data_source == null)
                return;

            var sensors = data_source.read_sensors();
            if (sensors != null)
            {
                sensors.name = this.info.Name;
                sensors.source_id = this.unique_plugin_identifier;
                sensors.identifier = this.unique_plugin_identifier;
                sensor_data = sensors;
                sensor_update = true;
            }
        }
コード例 #10
0
 /// <summary>
 /// abort export plugin
 /// </summary>
 public void stop_instance()
 {
     data_source = null;
     sensor_data = null;
 }