Exemplo n.º 1
0
        private void WriteSensorProperty(ISensorProperty sp, BinaryWriter writer)
        {
            var ms = new MemoryStream();

            using (var bw = new BinaryWriter(ms)) {
                try {
                    var code   = lookup[sp.GetType().Name];
                    var parser = parsers[code];
                    bw.Write((int)code);
                    if (parser.Write(sp, bw))
                    {
                        bw.Flush();
                        writer.Write(ms.ToArray());
                    }
                } catch (Exception e) {
                    Log.E(this, "Failed to write sensor property {" + sp.GetType().Name + "} to writer", e);
                }
            }
        }
Exemplo n.º 2
0
        private void WriteSensorProperty(ISensorProperty property, BinaryWriter writer)
        {
            var name = property.GetType();

            writer.Write(name.Name);

            if (property is AlternateUnitSensorProperty)
            {
                var sp = property as AlternateUnitSensorProperty;
                writer.Write(UnitLookup.GetCode(sp.unit));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Inserts the sensor property into the given index within the manifold.
 /// </summary>
 /// <returns><c>true</c>, if sensor property was inserted, <c>false</c> otherwise.</returns>
 /// <param name="">.</param>
 public bool InsertSensorProperty(ISensorProperty sensorProperty, int index)
 {
     if (HasSensorPropertyOfType(sensorProperty.GetType()))
     {
         return(false);
     }
     else
     {
         sensorProperties.Insert(index, sensorProperty);
         NotifyOfEvent(ManifoldEvent.EType.SensorPropertyAdded, index);
         return(true);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Inserts the sensor property into the given index within the manifold.
 /// </summary>
 /// <returns><c>true</c>, if sensor property was inserted, <c>false</c> otherwise.</returns>
 /// <param name="">.</param>
 public bool InsertSensorProperty(ISensorProperty sensorProperty, int index)
 {
     if (HasSensorPropertyOfType(sensorProperty.GetType()))
     {
         return(false);
     }
     else
     {
         sensorProperties.Insert(index, sensorProperty);
         NotifyOfEvent(new SensorEvent(SensorEvent.EType.LinkedSensorAdded, this, index));
         return(true);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds the sensor property to the manifold if the manifold does not already have a
 /// sensor property of the given type.
 /// </summary>
 /// <param name="sensorProperty">Sensor property.</param>
 /// <returns>True if the property was added, false if the manifold already has the property.</returns>
 public bool AddSensorProperty(ISensorProperty sensorProperty)
 {
     if (HasSensorPropertyOfType(sensorProperty.GetType()))
     {
         return(false);
     }
     else
     {
         if (sensorProperty is SecondarySensorProperty)
         {
             sensorProperties.Insert(0, sensorProperty);
             NotifyOfEvent(new SensorEvent(SensorEvent.EType.SensorPropertyAdded, this, 0));
             return(true);
         }
         else
         {
             sensorProperties.Add(sensorProperty);
             NotifyOfEvent(SensorEvent.EType.SensorPropertyAdded);
             return(true);
         }
     }
 }
        public static string GetCodeFromSensorProperty(ISensorProperty sp)
        {
            var type = sp.GetType();

            if (typeof(AlternateUnitSensorProperty).Equals(type))
            {
                return("Alternate");
            }
            else if (typeof(PTChartSensorProperty).Equals(type))
            {
                return("Pressure");
            }
            else if (typeof(MinSensorProperty).Equals(type))
            {
                return("Minimum");
            }
            else if (typeof(MaxSensorProperty).Equals(type))
            {
                return("Maximum");
            }
            else if (typeof(HoldSensorProperty).Equals(type))
            {
                return("Hold");
            }
            else if (typeof(RateOfChangeSensorProperty).Equals(type))
            {
                return("Rate");
            }
            else if (typeof(SuperheatSubcoolSensorProperty).Equals(type))
            {
                return("Superheat");
            }
            else
            {
//        Log.D(typeof(RemoteAnalyzerLH).Name, "Cannot find code for sensor property: " + sp.GetType().Name + ". Returning null.");
                return(null);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds the sensor property to the manifold if the manifold does not already have a
        /// sensor property of the given type.
        /// </summary>
        /// <param name="sensorProperty">Sensor property.</param>
        /// <returns>True if the property was added, false if the manifold already has the property.</returns>
        public bool AddSensorProperty(ISensorProperty sensorProperty)
        {
            if (HasSensorPropertyOfType(sensorProperty.GetType()))
            {
                return(false);
            }
            else
            {
                if (sensorProperty is SecondarySensorProperty)
                {
                    sensorProperties.Insert(0, sensorProperty);
                    NotifyOfEvent(ManifoldEvent.EType.SensorPropertyAdded, 0);

                    return(true);
                }
                else
                {
                    sensorProperties.Add(sensorProperty);
                    NotifyOfEvent(ManifoldEvent.EType.SensorPropertyAdded, sensorProperties.Count - 1);

                    return(true);
                }
            }
        }