示例#1
0
        /// <summary>
        /// Loads the sensor list from an xml string
        /// </summary>
        /// <param name="xml">An input string for an xml sensor list</param>
        public void FromXML(string xml)
        {
            XmlDocument dom = new XmlDocument();

            dom.LoadXml(xml);
            XmlNode xNode = dom.DocumentElement;

            if ((xNode.Name == SENSORS_ELEMENT) && (xNode.HasChildNodes))
            {
                foreach (XmlNode jNode in xNode.ChildNodes)
                {
                    if (jNode.Name == Sensor.SENSOR_ELEMENT)
                    {
                        SensorClasses sensorClass = SensorClasses.Unknown;
                        SensorTypes   sensorType  = SensorTypes.UNKNOWN;
                        foreach (XmlAttribute jAttribute in jNode.Attributes)
                        {
                            if (jAttribute.Name == CLASS_ATTRIBUTE)
                            {
                                sensorClass = (SensorClasses)Enum.Parse(typeof(SensorClasses), jAttribute.Value, true);
                            }
                            else if (jAttribute.Name == TYPE_ATTRIBUTE)
                            {
                                sensorType = (SensorTypes)Enum.Parse(typeof(SensorTypes), jAttribute.Value, true);
                            }
                        }

                        if (sensorType == SensorTypes.ACCEL)
                        {
                            Sensor sensor = null;
#if (PocketPC)
                            if (sensorClass == SensorClasses.HTCDiamondTouch)
                            {
                                sensor = new HTCDiamondTouch();
                            }
                            else
#endif
                            if (sensorClass == SensorClasses.MITes)
                            {
                                sensor = new MITe();
                            }
                            else if (sensorClass == SensorClasses.Sparkfun)
                            {
                                sensor = new Sparkfun();
                            }
                            else if (sensorClass == SensorClasses.Wockets)
                            {
                                sensor = new Wocket();
                            }
                            else if (sensorClass == SensorClasses.HTCDiamondTouch)
                            {
                                sensor = new HTCDiamondTouch();
                            }
                            sensor.FromXML(jNode.OuterXml);
                            this.Insert(sensor._ID, sensor);
                        }
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// A constructor that initializes the sensor type and class
 /// </summary>
 /// <param name="type"></param>
 /// <param name="classname"></param>
 public Sensor(SensorTypes type, SensorClasses classname)
 {
     this._Class        = classname;
     this._Type         = type;
     this._SamplingRate = 0;
     this._Saving       = true;
 }
示例#3
0
        /// <summary>
        /// A method that populates a sensor object from an XML string
        /// </summary>
        /// <param name="xml">An input XML string that describes the sensor</param>
        public virtual void FromXML(string xml)
        {
            XmlDocument dom = new XmlDocument();

            dom.LoadXml(xml);
            XmlNode iNode = dom.DocumentElement;

            if (iNode.Name == SENSOR_ELEMENT)
            {
                foreach (XmlAttribute iAttribute in iNode.Attributes)
                {
                    if (iAttribute.Name == CLASS_ATTRIBUTE)
                    {
                        this._Class = (SensorClasses)Enum.Parse(typeof(SensorClasses), iAttribute.Value, true);
                    }
                    else if (iAttribute.Name == TYPE_ATTRIBUTE)
                    {
                        this._Type = (SensorTypes)Enum.Parse(typeof(SensorTypes), iAttribute.Value, true);
                    }
                }

                foreach (XmlNode jNode in iNode.ChildNodes)
                {
                    foreach (XmlAttribute jAttribute in jNode.Attributes)
                    {
                        if ((jNode.Name == ID_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == SR_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                        {
                            this._SamplingRate = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == Receiver.RECEIVER_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._Receiver     = new Receivers.GenericReceiver();
                            this._Receiver._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == Decoder.DECODER_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._Decoder     = new Decoders.Accelerometers.GenericDecoder();
                            this._Decoder._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == LOCATION_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                        {
                            this._Location = jAttribute.Value;
                        }
                        else if ((jNode.Name == DESCRIPTION_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                        {
                            this._Description = jAttribute.Value;
                        }
                    }
                }
            }
        }
示例#4
0
 /// <summary>
 /// A constructor that intializes an accelerometer
 /// </summary>
 /// <param name="sensorclass">Specifies the class of the sensor (e.g. wocket, MITes)</param>
 public Accelerometer(SensorClasses sensorclass) : base(SensorTypes.ACCEL, sensorclass)
 {
     this._Calibration = new Calibration();
 }
示例#5
0
 /// <summary>
 /// A constructor that intializes an accelerometer
 /// </summary>
 /// <param name="sensorclass">Specifies the class of the sensor (e.g. wocket, MITes)</param>
 public Accelerometer(SensorClasses sensorclass)
     : base(SensorTypes.ACCEL,sensorclass)
 {
     this._Calibration = new Calibration();
 }
示例#6
0
文件: Sensor.cs 项目: katadam/wockets
        /// <summary>
        /// A method that populates a sensor object from an XML string
        /// </summary>
        /// <param name="xml">An input XML string that describes the sensor</param>
        public virtual void FromXML(string xml)
        {
            XmlDocument dom = new XmlDocument();
            dom.LoadXml(xml);
            XmlNode iNode = dom.DocumentElement;
            if (iNode.Name == SENSOR_ELEMENT)
            {

                foreach (XmlAttribute iAttribute in iNode.Attributes)
                {
                    if (iAttribute.Name == CLASS_ATTRIBUTE)
                        this._Class =  (SensorClasses)Enum.Parse(typeof(SensorClasses), iAttribute.Value,true);
                    else if (iAttribute.Name == TYPE_ATTRIBUTE)
                        this._Type = (SensorTypes)Enum.Parse(typeof(SensorTypes), iAttribute.Value,true);
                }

                foreach (XmlNode jNode in iNode.ChildNodes)
                {
                    foreach (XmlAttribute jAttribute in jNode.Attributes)
                    {
                        if ((jNode.Name == ID_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                            this._ID = Convert.ToInt32(jAttribute.Value);
                        else if ((jNode.Name == SR_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                            this._SamplingRate = Convert.ToInt32(jAttribute.Value);
                        else if ((jNode.Name == Receiver.RECEIVER_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._Receiver = new Receivers.GenericReceiver();
                            this._Receiver._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == Decoder.DECODER_ELEMENT) && (jAttribute.Name == ID_ATTRIBUTE))
                        {
                            this._Decoder = new Decoders.Accelerometers.GenericDecoder();
                            this._Decoder._ID = Convert.ToInt32(jAttribute.Value);
                        }
                        else if ((jNode.Name == LOCATION_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                            this._Location = jAttribute.Value;
                        else if ((jNode.Name == DESCRIPTION_ELEMENT) && (jAttribute.Name == TEXT_ATTRIBUTE))
                            this._Description = jAttribute.Value;

                    }
                }
            }
        }
示例#7
0
文件: Sensor.cs 项目: katadam/wockets
 /// <summary>
 /// A constructor that initializes the sensor type and class
 /// </summary>
 /// <param name="type"></param>
 /// <param name="classname"></param>
 public Sensor(SensorTypes type,SensorClasses classname)
 {
     this._Class = classname;
     this._Type = type;
     this._SamplingRate = 0;
     this._Saving = true;
 }