예제 #1
0
        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;
        }
예제 #2
0
 /// 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);
 }
예제 #3
0
 /// 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);
 }
예제 #6
0
 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);
 }
예제 #7
0
        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);
        }
예제 #8
0
        public void Connect()
        {
            // Connect MQTT clients
            ConnectMqttForever($"sender-{Guid.NewGuid()}");

            // Attach Commands to CmdMessenger
            CmdMessenger.Attach(OnUnknownCommand);
            CmdMessenger.Attach((int)Commands.TopicMessage, OnTopicMessageCommand);
        }
예제 #9
0
 /// 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);
 }
예제 #10
0
 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);
 }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
    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);
 }
예제 #16
0
파일: Arduino.cs 프로젝트: cacella/1209
 /// Attach command call backs.
 private void AttachCommandCallBacks()
 {
     _cmdMessenger.Attach(OnUnknownCommand);
     _cmdMessenger.Attach((int)Command.Move, OnMove);
     _cmdMessenger.Attach((int)Command.Acknowledge, OnAcknowledge);
 }
예제 #17
0
 private void AttachCommandCallBacks()
 {
     cmdMessenger.Attach((int)Command.kMeasurement, OnMeasurement);
     cmdMessenger.Attach((int)Command.kOutOfRange, OnOutOfRange);
     cmdMessenger.Attach((int)Command.kDisplayStateResp, OnDisplayStateResp);
 }
예제 #18
0
        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);
 }
예제 #20
0
 /// <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);
 }
예제 #21
0
 private void AttachCommandCallBacks()
 {
     _cmdMessenger.Attach(OnUnknownCommand);
     _cmdMessenger.Attach((int)Command.Button1, OnButton1);
     _cmdMessenger.Attach((int)Command.Button2, OnButton2);
 }
예제 #22
0
 private void AttachCommandCallBacks()
 {
     _cmdMessenger.Attach(_command["AreYouReady"], OnAreYouReadyCommand);
     _cmdMessenger.Attach(_command["YouAreReady"], OnYouAreReadyCommand);
 }
예제 #23
0
 /// Attach command call backs.
 protected void AttachCommandAction(Commands cmd, Action <ReceivedCommand> receivedAction)
 {
     _cmdMessenger.Attach((int)cmd, args => receivedAction(args));
 }
예제 #24
0
 /// <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);
 }
예제 #26
0
 private void AttachCommandCallBacks()
 {
     _cmdMessenger.Attach(Common.OnUnknownCommand);
 }