private static bool CheckConnectedStateInVector(MCUBoard board, string boardStateName, ref bool waitingBoardReconnect, NewVectorReceivedArgs vector) { var vectorState = (BaseSensorBox.ConnectionState)(int) vector[boardStateName]; var connected = vectorState >= BaseSensorBox.ConnectionState.Connected; if (waitingBoardReconnect && connected) { CALog.LogData(LogID.B, $"resuming switchboard actions after reconnect on {board.ToShortDescription()}"); waitingBoardReconnect = false; } else if (!waitingBoardReconnect && !connected) { CALog.LogData(LogID.B, $"stopping switchboard actions while connection is reestablished - state: {vectorState} - {board.ToShortDescription()}"); waitingBoardReconnect = true; } return(connected); }
public void SendVector(List <double> vector, DateTime timestamp) { if (vector.Count() != _vectorDescription.Length) { throw new ArgumentException($"wrong vector length (input, expected): {vector.Count} <> {_vectorDescription.Length}"); } if (timestamp <= _lastTimestamp) { CALog.LogData(LogID.B, $"non changing or out of order timestamp received - vector ignored: last recorded {_lastTimestamp} vs received {timestamp}"); return; } lock (_queue) if (_queue.Count < 10000) // if sending thread can't catch up, then drop packages. { _queue.Enqueue(new DataVector { timestamp = timestamp, vector = vector }); _lastTimestamp = timestamp; } }
public void LogData(string message) => CALog.LogData(LogID.B, FormatMessage(message));
private void WaitForLoopStopped(object sender, EventArgs args) { CALog.LogData(LogID.A, "waiting for switchboards control loops to finish actions and set ports to their default value"); _boardControlLoopsStopped.Task.Wait(); CALog.LogData(LogID.A, "finished waiting for switchboards loops"); }