コード例 #1
0
 /// <summary>
 /// Public constructor initializing the fields of the AbstractSensor class object.
 /// </summary>
 /// <param name="sensorType">Value for the field sensorType.</param>
 /// <param name="sensorState">Value for the field sensorState.</param>
 /// <param name="measurementInterval">Value for the field measurementInterval.</param>
 /// <param name="measuredValue">Value for the field measuredValue.</param>
 public AbstractSensor(string sensorType, string sensorState, int?measurementInterval, int?measuredValue)
 {
     UniqueIdentificator = UniqueSensorIdentifier.getInstance().CreateUniqueSensorIdentifier();
     SensorType          = sensorType;
     SensorState         = null;
     MeasurementInterval = measurementInterval;
     MeasuredValue       = 0;
 }
コード例 #2
0
 /// <summary>
 ///  GetInstance method returns an object of the UniqueSensorIdentifier class.
 /// </summary>
 /// <returns>A new object of the UniqueSensorIdentifier class if the UniqueSensorIdentifier object is created for the first time, otherwise the previously created UniqueSensorIdentifier object is returned. </returns>
 public static UniqueSensorIdentifier getInstance()
 {
     if (instance == null)
     {
         instance = new UniqueSensorIdentifier();
     }
     return(instance);
 }
コード例 #3
0
        /// <summary>
        /// ReadMeasuringSensorsJson method reads measuring sensors from Json.
        /// </summary>
        /// <param name="path"> Specifies the path to the json file. </param>
        /// <returns> A list of objects of the AbstractSensor class. </returns>
        public List <AbstractSensor> ReadMeasuringSensorsJson(string path)
        {
            List <AbstractSensor> ListMeasuringSensor = new List <AbstractSensor>();

            using (StreamReader sr = new StreamReader(path))
            {
                string jsonString = File.ReadAllText(path);
                ReflectionJsonArrayMeasuringSensor reflectionJsonArrayMeasuringSensor = JsonConvert.DeserializeObject <ReflectionJsonArrayMeasuringSensor>(jsonString);
                UniqueSensorIdentifier             uniqueSensorIdentifier             = UniqueSensorIdentifier.getInstance();

                for (int i = 0; i < reflectionJsonArrayMeasuringSensor.arrayMeasuringSensor.Length; i++)
                {
                    ListMeasuringSensor.Add(new AbstractSensor(reflectionJsonArrayMeasuringSensor.arrayMeasuringSensor[i]._SensorType, null,
                                                               reflectionJsonArrayMeasuringSensor.arrayMeasuringSensor[i].MeasurementInterval, null));
                }
            }
            return(ListMeasuringSensor);
        }