public static MessageBody CreateTemperatureData(int counter, DataGenerationPolicy policy, bool reset = false) { if (reset) { TemperatureDataFactory.CurrentMachineTemperature = policy.CalculateMachineTemperature(); } else { TemperatureDataFactory.CurrentMachineTemperature = policy.CalculateMachineTemperature(TemperatureDataFactory.CurrentMachineTemperature); } var machinePressure = policy.CalculatePressure(TemperatureDataFactory.CurrentMachineTemperature); var ambientTemperature = policy.CalculateAmbientTemperature(); var ambientHumidity = policy.CalculateHumidity(); var messageBody = new MessageBody { Machine = new Machine { Temperature = TemperatureDataFactory.CurrentMachineTemperature, Pressure = machinePressure }, Ambient = new Ambient { Temperature = ambientTemperature, Humidity = ambientHumidity }, TimeCreated = string.Format("{0:O}", DateTime.Now) }; return(messageBody); }
public static MessageBody CreateTemperatureData(int counter, DataGenerationPolicy policy, bool reset = false) { if (reset) { TemperatureDataFactory.CurrentMotorTemperature = policy.CalculateMotorTemperature(); TemperatureDataFactory.CurrentMotorFrequency = policy.CalculateMotorFrequency(); TemperatureDataFactory.CurrentMotorCurrent = policy.CalculateMotorCurrent(); } else { TemperatureDataFactory.CurrentMotorTemperature = policy.CalculateMotorTemperature(TemperatureDataFactory.CurrentMotorTemperature); TemperatureDataFactory.CurrentMotorFrequency = policy.CalculateMotorFrequency(TemperatureDataFactory.CurrentMotorFrequency); TemperatureDataFactory.CurrentMotorCurrent = policy.CalculateMotorCurrent(TemperatureDataFactory.CurrentMotorCurrent); } var ambientTemperature = policy.CalculateAmbientTemperature(); var ambientHumidity = policy.CalculateHumidity(); var currentVoltage = policy.CalculateVoltage(); var currentMotorPower = policy.CalculatePower(currentVoltage, TemperatureDataFactory.CurrentMotorCurrent); var currentMotorSpeed = policy.CalculateSpeed(TemperatureDataFactory.CurrentMotorFrequency, 1); var currentTime = DateTime.Now; var messageBody = new MessageBody { Motor = new Motor { Temperature = TemperatureDataFactory.CurrentMotorTemperature, Current = TemperatureDataFactory.CurrentMotorCurrent, Frequency = TemperatureDataFactory.CurrentMotorFrequency, Power = TemperatureDataFactory.CurrentMotorPower, Speed = currentMotorSpeed, Torque = policy.CalculateTorque(currentMotorSpeed, currentMotorPower), Voltage = currentVoltage, Energy = policy.CalculateMotorEnergy(currentMotorPower, TemperatureDataFactory.CurrentMotorPower, TemperatureDataFactory.LastTime) }, Ambient = new Ambient { Temperature = ambientTemperature, Humidity = ambientHumidity }, TimeCreated = string.Format("{0:O}", currentTime) }; TemperatureDataFactory.CurrentMotorPower = currentMotorPower; TemperatureDataFactory.LastTime = currentTime; return(messageBody); }
public static MessageBody CreateTemperatureData(int counter, DataGenerationPolicy policy, bool resetTemperature = false, bool resetOverhaul = false) { if (resetTemperature) { TemperatureDataFactory.CurrentMachineTemperature = policy.CalculateMachineTemperature(); } else { TemperatureDataFactory.CurrentMachineTemperature = policy.CalculateMachineTemperature(TemperatureDataFactory.CurrentMachineTemperature); } var machinePressure = policy.CalculatePressure(TemperatureDataFactory.CurrentMachineTemperature); var ambientTemperature = policy.CalculateAmbientTemperature(); var ambientHumidity = policy.CalculateHumidity(); TemperatureDataFactory.CurrentRunTimeSinceProduction = policy.CalculateRunTimeSinceProduction(TemperatureDataFactory.CurrentRunTimeSinceProduction); TemperatureDataFactory.CurrentRunTimeSinceMaintenance = policy.CalculateRunTimeSinceMaintenance(TemperatureDataFactory.CurrentRunTimeSinceMaintenance); if (resetOverhaul) { TemperatureDataFactory.CurrentRunTimeSinceOverhaul = policy.CalculateRunTimeSinceOverhaul(1); } else { TemperatureDataFactory.CurrentRunTimeSinceOverhaul = policy.CalculateRunTimeSinceOverhaul(TemperatureDataFactory.CurrentRunTimeSinceOverhaul); } var messageBody = new MessageBody { Machine = new Machine { Temperature = TemperatureDataFactory.CurrentMachineTemperature, Pressure = machinePressure, RunTimeSinceProduction = TemperatureDataFactory.CurrentRunTimeSinceProduction, RunTimeSinceMaintenance = TemperatureDataFactory.CurrentRunTimeSinceMaintenance, RunTimeSinceOverhaul = TemperatureDataFactory.CurrentRunTimeSinceOverhaul, }, Ambient = new Ambient { Temperature = ambientTemperature, Humidity = ambientHumidity }, TimeCreated = string.Format("{0:O}", DateTime.Now) }; return(messageBody); }