コード例 #1
0
 internal void Update(SensorEnergyLog newEnergyLog)
 {
     this.Watts1     = newEnergyLog.Watts1;
     this.Watts2     = newEnergyLog.Watts2;
     this.Watts3     = newEnergyLog.Watts3;
     this.WattsTotal = newEnergyLog.WattsTotal;
 }
コード例 #2
0
        internal void CalculateDuration(float logDurationMode, SensorEnergyLog lastEnergyLog)
        {
            var calDuration   = (this.UnixTime - lastEnergyLog.UnixTime);
            var eightyPercent = logDurationMode * 0.80;

            if ((calDuration < (logDurationMode - eightyPercent) || (calDuration > (logDurationMode + eightyPercent))))
            {
                this.Duration = logDurationMode;
            }
            else
            {
                this.Duration = calDuration;
            }
        }
コード例 #3
0
        internal static SensorEnergyLog Parse(Sensor sensor, Func <long, long> GetSensorDimTimeId, string contentLogItem)
        {
            var contenValues    = contentLogItem.Split(";");
            var unixTime        = long.Parse(contenValues[0]);
            var watts1          = float.Parse(contenValues[1]);
            var watts2          = float.Parse(contenValues[2]);
            var watts3          = float.Parse(contenValues[3]);
            var wattsTotal      = watts1 + watts2 + watts3;
            var sensorEnergyLog = new SensorEnergyLog()
            {
                SensorId        = sensor.Id,
                SensorDimTimeId = GetSensorDimTimeId(unixTime),
                UnixTime        = unixTime,
                Duration        = sensor.LogDurationMode,
                Watts1          = watts1 * sensor.DefaultToConvert,
                Watts2          = watts2 * sensor.DefaultToConvert,
                Watts3          = watts3 * sensor.DefaultToConvert,
                WattsTotal      = wattsTotal * sensor.DefaultToConvert,
                ConvertToUnits  = sensor.DefaultToConvert
            };

            return(sensorEnergyLog);
        }