/// <summary> /// Part of interface TFDataSink - initalize plugin /// </summary> /// <returns>signal success with true</returns> public override bool Init() { LcdConfig.Instance.ShowConfig(); if (PerformConnect() && CollectBrickletInformations()) { // interval at which timer elapses (in ms) int delay = CommonUtils.DefaultDelay; // buffer the timer actively waits (in ms) // this exists to make sure we don't accidentally skip an interval at which // the timestamp could have been written to the lcd display int delayBuffer = 100; TimeStampDisplayTimer = new System.Timers.Timer(CommonUtils.DefaultDelay); TimeStampDisplayTimer.Elapsed += (o, args) => { CommonUtils.WaitForCleanTimestamp(delay / 1000, delayBuffer); lock (WriteLock) { // Display timestamp Bricklet.WriteLine(0, 0, DateTime.Now.ToString(LcdConfig.Instance.TimestampFormat)); } }; // CommonUtils.WaitForCleanTimestamp(delay / 1000, delayBuffer); TimeStampDisplayTimer.Start(); return(true); } return(false); }
/// <summary> /// Part of interface TFDataSink - perform action with given data /// </summary> /// <param name="SensorValue"></param> public override void HandleValue(MeasurementValue SensorValue) { if (Bricklet == null) { return; } if (SensorValue.SortOrder == LcdConfig.Instance.SkipIndex) { return; } // Calculation of position in dependency of the sort order byte posX = (byte)((SensorValue.SortOrder % 2) * 10); byte posY = (byte)((SensorValue.SortOrder / 2) + 1); string MeasurementValueData = string.Format("{0,7:####.00} {1}", SensorValue.Value, SensorValue.Unit); lock (WriteLock) { Bricklet.WriteLine(posY, posX, MeasurementValueData); } }