Пример #1
0
 public OutputRecord(EnergyRecord record, string eventName)
 {
     CTime = record.CTime;
     Value = record.EnergyData;
     Event = eventName;
     if (!string.IsNullOrEmpty(eventName))
     {
         EventValue = Value.ToString();
     }
     else
     {
         EventValue = string.Empty;
     }
 }
Пример #2
0
        public static DataOutput GetAverage(List <DataOutput> outputs)
        {
            DataOutput output         = new DataOutput();
            var        stopProcessing = false;

            output.EnergyRecords = new List <EnergyRecord>(outputs[0].EnergyRecords.Count);
            output.PowerRecords  = new List <PowerRecord>(outputs[0].PowerRecords.Count);
            output.FrameRecords  = new List <FrameRecord>(outputs[0].FrameRecords.Count);
            int sampleSize = outputs[0].PowerRecords.Count;

            for (int i = 0; i < sampleSize; ++i)
            {
                var energyRecord = new EnergyRecord()
                {
                    SampleNumber = 0,
                    EnergyData   = 0F,
                    CTime        = 0F,
                    Duration     = 0F
                };

                var powerRecord = new PowerRecord()
                {
                    SampleNumber = 0,
                    PowerData    = 0F,
                    CTime        = 0F,
                    Duration     = 0F
                };

                for (int k = 0; k < outputs.Count; ++k)
                {
                    if (i >= outputs[k].EnergyRecords.Count || i >= outputs[k].PowerRecords.Count)
                    {
                        stopProcessing = true;
                        break; //If final few samples don't match, we stop processing and skip the last few records. This usually only amounts to the last 1-2 seconds of the SocWatch run.
                    }
                    energyRecord.SampleNumber = outputs[k].EnergyRecords[i].SampleNumber;
                    energyRecord.CTime       += outputs[k].EnergyRecords[i].CTime;
                    energyRecord.Duration    += outputs[k].EnergyRecords[i].Duration;
                    energyRecord.EnergyData  += outputs[k].EnergyRecords[i].EnergyData;

                    powerRecord.SampleNumber = outputs[k].PowerRecords[i].SampleNumber;
                    powerRecord.CTime       += outputs[k].PowerRecords[i].CTime;
                    powerRecord.Duration    += outputs[k].PowerRecords[i].Duration;
                    powerRecord.PowerData   += outputs[k].PowerRecords[i].PowerData;
                }

                if (stopProcessing)
                {
                    break;
                }

                //Get Average across one row and store it
                energyRecord.CTime      /= outputs.Count;
                energyRecord.Duration   /= outputs.Count;
                energyRecord.EnergyData /= outputs.Count;
                output.EnergyRecords.Add(energyRecord);

                powerRecord.CTime     /= outputs.Count;
                powerRecord.Duration  /= outputs.Count;
                powerRecord.PowerData /= outputs.Count;
                output.PowerRecords.Add(powerRecord);
            }

            stopProcessing = false;
            for (int i = 0; i < outputs[0].FrameRecords.Count; ++i)
            {
                var frameRecord = new FrameRecord
                {
                    SampleCount   = 0,
                    CTime         = 0F,
                    Energy        = 0,
                    EnergyAverage = 0,
                    MaxEnergy     = 0,
                    MinEnergy     = 0,
                    Power         = 0,
                    PowerAverage  = 0,
                    MaxPower      = 0,
                    MinPower      = 0
                };

                for (int k = 0; k < outputs.Count; ++k)
                {
                    if (i >= outputs[k].FrameRecords.Count)
                    {
                        stopProcessing = true;
                        break;
                    }
                    frameRecord.FrameNumber    = outputs[k].FrameRecords[i].FrameNumber;
                    frameRecord.CTime         += outputs[k].FrameRecords[i].CTime;
                    frameRecord.Energy        += outputs[k].FrameRecords[i].Energy;
                    frameRecord.Power         += outputs[k].FrameRecords[i].Power;
                    frameRecord.EnergyAverage += outputs[k].FrameRecords[i].EnergyAverage;
                    frameRecord.PowerAverage  += outputs[k].FrameRecords[i].PowerAverage;
                    frameRecord.MaxPower      += outputs[k].FrameRecords[i].MaxPower;
                    frameRecord.MaxEnergy     += outputs[k].FrameRecords[i].MaxEnergy;
                    frameRecord.MinPower      += outputs[k].FrameRecords[i].MinPower;
                    frameRecord.MinEnergy     += outputs[k].FrameRecords[i].MinEnergy;
                    frameRecord.SampleCount   += outputs[k].FrameRecords[i].SampleCount;
                }

                if (stopProcessing)
                {
                    break;
                }

                frameRecord.CTime         /= outputs.Count;
                frameRecord.Energy        /= outputs.Count;
                frameRecord.Power         /= outputs.Count;
                frameRecord.EnergyAverage /= outputs.Count;
                frameRecord.PowerAverage  /= outputs.Count;
                frameRecord.MaxPower      /= outputs.Count;
                frameRecord.MaxEnergy     /= outputs.Count;
                frameRecord.MinPower      /= outputs.Count;
                frameRecord.MinEnergy     /= outputs.Count;
                frameRecord.SampleCount   /= outputs.Count;
                output.FrameRecords.Add(frameRecord);
            }

            return(output);
        }