public BoardInterface(Control c) { OutputPins = new List <NamedPin>(); InputPins = new List <NamedPin>(); _transport = new SerialTransport() { CurrentSerialSettings = { DtrEnable = false, BaudRate = 9600 } }; _messenger = new CmdMessenger(_transport, BoardType.Bit32) { PrintLfCr = false, ControlToInvokeOn = c }; _messenger.NewLineReceived += Messenger_NewLineReceived; _messenger.NewLineSent += Messenger_NewLineSent; _messenger.Attach(Messenger_UnknownCommand); _messenger.Attach((int)Command.Debug, Messenger_DebugCommand); _messenger.Attach((int)Command.InitializationFinished, Messenger_InitialzationFinishedCommand); _messenger.Attach((int)Command.PinSet, Messenger_PinSetCommand); _connectionManager = new SerialConnectionManager(_transport as SerialTransport, _messenger, (int)Command.Watchdog, COMMUNICATION_IDENTIFIER) { WatchdogEnabled = true, DeviceScanBaudRateSelection = false }; _connectionManager.Progress += ConnectionManager_Progress; _connectionManager.ConnectionFound += ConnectionManager_ConnectionFound; _connectionManager.ConnectionTimeout += ConnectionManager_ConnectionTimeout; }
/// Attach command call backs. private void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Acknowledge, OnAcknowledge); _cmdMessenger.Attach((int)Command.Error, OnError); _cmdMessenger.Attach((int)Command.PlotDataPoint, OnPlotDataPoint); }
/// Attach command call backs. protected virtual void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Acknowledge, OnAcknowledge); _cmdMessenger.Attach((int)Command.Error, OnError); _cmdMessenger.Attach((int)Command.kVerResult, OnVersion); }
// ------------------ Command Callbacks ------------------------- private void AttachCommandCallBacks() { _cmdMessenger.Attach(_command["RequestResetAcknowledge"], OnRequestResetAcknowledge); _cmdMessenger.Attach(_command["ReceiveSeries"], OnReceiveSeries); _cmdMessenger.Attach(_command["DoneReceiveSeries"], OnDoneReceiveSeries); _cmdMessenger.Attach(_command["AckSendSeries"], OnAckSendSeries); }
private void AttachCommandCallBacks() { _cmdMessenger.Attach((int)EnumOperationTypes.ButtonInput, ButtonInputReceived); _cmdMessenger.Attach((int)EnumOperationTypes.EncoderInput, EncoderInputReceived); _cmdMessenger.Attach((int)EnumOperationTypes.ToggleInput, ToggleInputReceived); _cmdMessenger.Attach((int)EnumOperationTypes.Status, StatusReceived); _cmdMessenger.Attach((int)EnumOperationTypes.MuxToggleInput, MuxToggleInputReceived); }
private void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.CommReport, OnCommReport); _cmdMessenger.Attach((int)Command.ChannelFounded, OnChannelFounded); _cmdMessenger.Attach((int)Command.Triggered, OnTriggered); _cmdMessenger.Attach((int)Command.ReceiveData, OnReceiveData); }
private static CmdMessenger GetMessenger(SerialTransport transport) { var messenger = new CmdMessenger(transport, BoardType.Bit16); messenger.Attach(OnUnknownCommand); messenger.Attach((int)Command.Status, OnStatus); messenger.NewLineReceived += NewLineReceived; messenger.NewLineSent += NewLineSent; messenger.Connect(); return(messenger); }
public void Connect() { // Connect MQTT clients ConnectMqttForever($"sender-{Guid.NewGuid()}"); // Attach Commands to CmdMessenger CmdMessenger.Attach(OnUnknownCommand); CmdMessenger.Attach((int)Commands.TopicMessage, OnTopicMessageCommand); }
/// Attach command call backs. private void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Acknowledge, OnAcknowledge); _cmdMessenger.Attach((int)Command.Error, OnError); _cmdMessenger.Attach((int)Command.LapStatus, OnLapStatus); _cmdMessenger.Attach((int)Command.SetCamMsg, OnCamMsg); _cmdMessenger.Attach((int)Command.BtnStatus, OnBtnStatus); _cmdMessenger.Attach((int)Command.PjonBufferCt, OnPjonBufferCt); }
private void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Time, OnTimeIn); _cmdMessenger.Attach((int)Command.Thrust, OnThrustDataIn); _cmdMessenger.Attach((int)Command.Voltage, OnVoltageIn); _cmdMessenger.Attach((int)Command.Current, OnCurrentIn); _cmdMessenger.Attach((int)Command.Rpm, OnRpmIn); _cmdMessenger.Attach((int)Command.Throttle, OnThrottleIn); }
public async Task <bool> Setup() { _serialTransport = new SerialTransport { CurrentSerialSettings = { PortName = "COM3", BaudRate = 57600, DtrEnable = false } // object initializer }; _cmdMessenger = new CmdMessenger(_serialTransport, BoardType.Bit32); _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Acknowledge, OnAcknowledge); _cmdMessenger.Attach((int)Command.Error, OnError); _cmdMessenger.Attach((int)Command.TempChange, OnTempChange); _cmdMessenger.Attach((int)Command.SsrChange, OnSsrChange); _cmdMessenger.Attach((int)Command.HeaterChange, OnHeaterChange); _cmdMessenger.NewLineReceived += NewLineReceived; _cmdMessenger.NewLineSent += NewLineSent; IsConnected = _cmdMessenger.Connect(); if (IsConnected) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _eventAggregator.GetEvent <ConnectionStatusEvent>().Publish(new ConnectionStatus { Type = ConnectionStatus.EventType.Connected }); }); RequestStatus(); } return(IsConnected); }
public bool Setup() { _serialTransport = new SerialTransport { CurrentSerialSettings = { PortName = "COM4", BaudRate = 57600, DtrEnable = false } // object initializer }; _cmdMessenger = new CmdMessenger(_serialTransport, BoardType.Bit32); _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Acknowledge, OnAcknowledge); _cmdMessenger.Attach((int)Command.Error, OnError); _cmdMessenger.Attach((int)Command.TempChange, OnTempChange); _cmdMessenger.Attach((int)Command.SsrChange, OnSsrChange); _cmdMessenger.Attach((int)Command.HeaterChange, OnHeaterChange); _cmdMessenger.NewLineReceived += NewLineReceived; _cmdMessenger.NewLineSent += NewLineSent; IsConnected = _cmdMessenger.Connect(); if (IsConnected) { ConnectionStatusEventHandler?.Invoke(this, new ConnectionStatusEvent { Type = ConnectionStatusEvent.EventType.Connected }); //TODO: Request Status } return(IsConnected); }
static BaseViewModel() { // Create Serial Port object // Note that for some boards (e.g. Sparkfun Pro Micro) DtrEnable may need to be true. _bluetoothTransport = new BluetoothTransport { DeviceName = "EMS01_1152" }; // Initialize the command messenger with the Serial Port transport layer // Set if it is communicating with a 16- or 32-bit Arduino board _cmdMessenger = new CmdMessenger(_bluetoothTransport, BoardType.Bit16); // Attach to NewLinesReceived for logging purposes _cmdMessenger.NewLineReceived += NewLineReceived; // Attach to NewLineSent for logging purposes _cmdMessenger.NewLineSent += NewLineSent; _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Commands.Acknowledge, OnAcknowledge); _cmdMessenger.Attach((int)Commands.Error, OnError); }
public void Open(string portName) { if (cmdMessenger != null) { Close(); } Debug.LogFormat("Opening port {0}.", portName); serialTransport.CurrentSerialSettings.PortName = portName; cmdMessenger = new CmdMessenger(serialTransport, BoardType.Bit16); #if UNITY_EDITOR if (debugNewLines) { cmdMessenger.NewLineReceived += NewLineReceived; cmdMessenger.NewLineSent += NewLineSent; } #endif cmdMessenger.Attach(OnUnknownCommand); cmdMessenger.Attach((int)Command.UnknownCommand, OnUnknownCommand); cmdMessenger.Attach((int)Command.InvalidArgument, OnInvalidArgument); cmdMessenger.Attach((int)Command.ReadyResponse, OnReadyResponse); cmdMessenger.Attach((int)Command.SetButtonColorResponse, OnSetButtonColorResponse); cmdMessenger.Attach((int)Command.TurnOffResponse, OnTurnOffResponse); cmdMessenger.Attach((int)Command.ButtonsStateUpdated, OnButtonsStateUpdated); var success = cmdMessenger.Connect(); Debug.Log(success ? "Connection succeeded." : "Connection failed."); if (success) { var command = new SendCommand((int)Command.ReadyRequest); cmdMessenger.SendCommand(command); } }
private void AttachCommandCallBacks() { _cmdMessenger.Attach((int)Command.aCheckResponse, OnReceiveCheckResponse); _cmdMessenger.Attach((int)Command.aGoNextSensor, OnGoNextSensor); }
/// Attach command call backs. private void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Move, OnMove); _cmdMessenger.Attach((int)Command.Acknowledge, OnAcknowledge); }
private void AttachCommandCallBacks() { cmdMessenger.Attach((int)Command.kMeasurement, OnMeasurement); cmdMessenger.Attach((int)Command.kOutOfRange, OnOutOfRange); cmdMessenger.Attach((int)Command.kDisplayStateResp, OnDisplayStateResp); }
public override void Connect(params string[] topics) { base.Connect(topics); CmdMessenger.Attach((int)Commands.SendBatch, OnSendBatchCommand); }
/// Attach command call backs. private void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.ReceivePlainTextFloatSeries, OnReceivePlainTextFloatSeries); _cmdMessenger.Attach((int)Command.ReceiveBinaryFloatSeries, OnReceiveBinaryFloatSeries); }
/// <summary> /// Attached the command callbacks from the serial communication /// </summary> private void AttachCommandCallBacks() { cmdMessenger.Attach((int)Command.kModelChanged, OnModelChanged); cmdMessenger.Attach((int)Command.kPartStatus, OnPartStatusChanged); }
private void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Button1, OnButton1); _cmdMessenger.Attach((int)Command.Button2, OnButton2); }
private void AttachCommandCallBacks() { _cmdMessenger.Attach(_command["AreYouReady"], OnAreYouReadyCommand); _cmdMessenger.Attach(_command["YouAreReady"], OnYouAreReadyCommand); }
/// Attach command call backs. protected void AttachCommandAction(Commands cmd, Action <ReceivedCommand> receivedAction) { _cmdMessenger.Attach((int)cmd, args => receivedAction(args)); }
/// <summary> /// Attachs the command call backs. /// </summary> private static void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Acknowledge, OnAcknowledge); _cmdMessenger.Attach((int)Command.Error, OnError); }
/// Attach command call backs. private void AttachCommandCallBacks() { _cmdMessenger.Attach(OnUnknownCommand); _cmdMessenger.Attach((int)Command.Status, OnStatus); _cmdMessenger.Attach((int)Command.Status, OnStatus); }
private void AttachCommandCallBacks() { _cmdMessenger.Attach(Common.OnUnknownCommand); }