private static void telegramTypeA(byte[] telegramBody) { Logger.Log(LogType.Info, "Received Telegram ->"); string logString = string.Empty; foreach (byte singleByte in telegramBody) { logString += $"{singleByte} "; } Logger.Log(LogType.Info, logString); byte[] byteTimeStamp = new byte[] { telegramBody[1], telegramBody[2], telegramBody[3], telegramBody[4] }; uint NTPtimeStamp = BitConverter.ToUInt32(byteTimeStamp, 0); DateTime timeStamp = new DateTime(1900, 1, 1, 0, 0, 0).AddSeconds(NTPtimeStamp); int posX = 0; for (int i = 7; i <= 22; i += 2) { TemperatureIndication temperatureIndication = new TemperatureIndication( timeStamp, posX++, telegramBody[6], BitConverter.ToInt16(new byte[] { telegramBody[i + 1], telegramBody[i] }, 0)); TemperatureSaver.AddTemperatureIndication(temperatureIndication); } }
static void Main(string[] args) { //string testPath = @"C:\Users\w7\Desktop\TemperatureServerSave_temp"; List <TemperatureIndication> temperatureIndications = args[0].LoadRecord(); //List<TemperatureIndication> temperatureIndications = testPath.LoadRecord(); List <TemperatureIndication> outputRecord = new List <TemperatureIndication>(); Converter converter = new Converter(); var appConfig = ConfigurationManager.AppSettings; foreach (TemperatureIndication temperatureIndication in temperatureIndications) { var convertedTemperature = converter.ConvertValue(temperatureIndication.Value); if (convertedTemperature > int.Parse(appConfig["MaxValue"])) { convertedTemperature = int.Parse(appConfig["MaxValueConvertTo"]); } else if (convertedTemperature < int.Parse(appConfig["MinValue"])) { convertedTemperature = int.Parse(appConfig["MinValueConvertTo"]); } TemperatureIndication modifiedRecord = new TemperatureIndication(temperatureIndication.DateTime, temperatureIndication.PosX, temperatureIndication.PosY, convertedTemperature); outputRecord.Add(modifiedRecord); } outputRecord.SaveRecord(args[0] + "Converted"); //outputRecord.SaveRecord(testPath + "Converted"); }
public static void AddTemperatureIndication(TemperatureIndication temperatureIndication) { lock (temperatureIndicationsPadLock) { temperatureIndications.Add(temperatureIndication); } }
private void DisplayIndication(int indicationPosition) { if (temperatureIndications.Count - 1 >= indicationPosition) { TemperatureIndication selectedIndication = temperatureIndications[indicationPosition]; lblTimestamp.Content = selectedIndication.DateTime.ToString(); SolidColorBrush solidColorBrush = new SolidColorBrush { Color = colors[ConvertFromAnalogToRGBValue(selectedIndication.Value, minColorValue, maxColorValue, 0, 764)] }; GraphicalTemperatureIndication displayElement = graphicalTemperatureIndications[selectedIndication.PosX, selectedIndication.PosY]; displayElement.rectangle.Fill = solidColorBrush; mainCanvas.Children.Remove(displayElement.textBlock); displayElement.textBlock = Text(selectedIndication.PosX * 41 + 7, selectedIndication.PosY * 41 + 12, selectedIndication.Value.ToString() + valueSuffix, Color.FromRgb(0, 0, 0)); if (shouldShowValues) { mainCanvas.Children.Add(displayElement.textBlock); } } }