protected override void ExecuteInternal(TeensyBatDevice device) { int totalSeconds = (int)Math.Round((DateTime.UtcNow - EpochStart).TotalSeconds); totalSeconds = totalSeconds + 1; device.Send(string.Format(CultureInfo.InvariantCulture, "CT{0}\n", totalSeconds)); }
protected override bool?HandleLine(TeensyBatDevice device, string data) { if (data.StartsWith("OK: ", StringComparison.OrdinalIgnoreCase)) { return(true); } if (data.StartsWith("ERR: ", StringComparison.OrdinalIgnoreCase)) { return(false); } return(null); }
protected override DeviceInfo HandleLine(TeensyBatDevice device, string data) { Match match = ConfigData.Match(data); if (match.Success) { DeviceInfo info = new DeviceInfo(); info.NodeId = int.Parse(match.Groups["NodeId"].Value, CultureInfo.InvariantCulture); info.CurrentDate = DateTime.ParseExact(match.Groups["Date"].Value, "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture); info.RecordingTime = DateTime.UtcNow; return(info); } return(null); }
public Task <TResult> Execute(TeensyBatDevice device) { Task <TResult> task = Task.Run(() => { try { _responseHandled.Reset(); device.LineReceived += DeviceOnLineReceived; if (device.IsConnected) { ExecuteInternal(device); WaitHandle.WaitAny(new[] { device.CancellationToken.Token.WaitHandle, _responseHandled }, Timeout); } } finally { device.LineReceived -= DeviceOnLineReceived; } return(_result); }); return(task); }
protected abstract TResult HandleLine(TeensyBatDevice device, string data);
protected abstract void ExecuteInternal(TeensyBatDevice device);
protected override void ExecuteInternal(TeensyBatDevice device) { device.Send("CP\n"); }