private static void SetButtonCommand(string[] args) { if (args.Length > 0) { SerialCommunication.SetLayout(args); } }
public ShellViewModel( IEventAggregator eventAggregator, SocketClient socketClient, RobotCommand moveCommand, ControllerClass controllerClass ) { _socketClient = socketClient; _dashboardClient = new SocketClient(eventAggregator); _roboServer = new SocketServer(eventAggregator); _robotCommand = moveCommand; _controllerClass = controllerClass; _eventAggregator = eventAggregator; _eventAggregator.Subscribe(this); _controllerClass.StartController(); _serial = new SerialCommunication(eventAggregator); _BTConnection = new BluetoothConnection(eventAggregator); ComPortList = SerialPort.GetPortNames(); BaudRateList = DataLists.GetBaudRates(); MotorStepTypeList = DataLists.GetStepTypes(); }
public void SubmitNotificationColor([FromBody] NotificationViewModel notification) { Console.WriteLine($"{notification.R} {notification.G} {notification.B}"); SerialCommunication.Inicialize(); SerialCommunication.Write($"#SETCR{notification.R}G{notification.G}B{notification.B}#\n"); SerialCommunication.Close(); }
public void SubmitNotificationRele([FromBody] NotificationViewModel notification) { Console.WriteLine($"{notification.Id}"); SerialCommunication.Inicialize(); SerialCommunication.Write($"#RELEI{notification.Id}#\n"); SerialCommunication.Close(); }
///</topbar params> public void connectSerial(Button btn) { string button_text = btn.GetComponentInChildren <Text>().text; int.TryParse(IF_baudrate.text, out int baudrate); if (baudrate < 9600 || baudrate > 120000) { baudrate = 9600; } if (button_text.Equals("Connect")) { try { _myserial = new SerialCommunication(IF_portname.text, baudrate); btn.GetComponentInChildren <Text>().text = "Disconnect"; text_state.text = "Connected"; } catch (UnityException e) { Debug.LogWarning("error when initial serial port! " + e); text_state.text = "Connect error"; } } else { _myserial.MySerial.Close(); btn.GetComponentInChildren <Text>().text = "Connect"; text_state.text = "Disconnected"; } }
public override CmdLineResult handleCommand(CmdLineStruct pCmd) { // Gestion héritée des commandes CmdLineResult lCmdLineResult = base.handleCommand(pCmd); if (lCmdLineResult.CmdAccepted) { return(lCmdLineResult); } // Sortie if (pCmd.Line == "q") { SerialCommunication.get().close(); return(new CmdLineResult(true, "", "", true, true)); } // Accès aux P, I, D de manière individuelle StateBase lNewState = null; if (lNewState != null) { setSubState(lNewState); } return(new CmdLineResult(true, "", "", true, false)); }
private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { if (!ArduinoSerialPort.IsOpen) { return; } string message; try { message = ArduinoSerialPort.ReadLine().Trim(); } catch (IOException ex) { Console.WriteLine(ex); return; } if (string.IsNullOrEmpty(message)) { return; } SerialCommunication serial = new SerialCommunication(message, SerialCommunication.Type.RECIEVE); Application.Current.Dispatcher.Invoke(delegate { SerialCommunicationList.Add(serial); arduinoSerialPort.HandleMessage(message); } ); }
/* * Uploads the commands to the Arduino */ public void Upload() { // Clear the parser _parser.ResetParser(); // Parse nodes, if returns false, stop uploading bool parseSucces = _parser.ParseNodes(); if (!parseSucces) { return; } // Optimize parser (Second parsing iteration) _parser.Optimize(); /* * Loop through command list and send * each command code as an individual byte * over the serial bus */ foreach (Command cmd in _parser.cmdList) { SerialCommunication.WriteToSerialPort(cmd.command); } // Send end upload code over serial bus SerialCommunication.WriteToSerialPort(END_PROGRAM); }
private static void EditButtonLayout(string[] args) { if (args.Length >= 3) { if (SerialCommunication.LayoutExists(args[0])) { switch (args[1]) { case "a": SerialCommunication.EditLayout(args[0].Trim(), 0, args.Skip(2).ToArray().ArrayString().Trim()); break; case "b": SerialCommunication.EditLayout(args[0].Trim(), 1, args.Skip(2).ToArray().ArrayString().Trim()); break; default: Console.WriteLine("Invalid Button"); break; } } else { Console.WriteLine("Layout does not exist!"); } } }
/// <summary> /// Establishes the SerialCommunication /// </summary> /// <param name="sender">Object that calls the function</param> /// <param name="e">Default, empty and useless event argument</param> public void Connect(Object sender, EventArgs e) { //Deactivate Button form1.ChangeConnectButtonState(false); connectDialog.ChangeConnectButtonState(false); //Searches all availible Prots for Sensor .. or disconnects if (!processData.sensorAnswer) { serial = new SerialCommunication(this); serial.NewSerialDataRecieved += new EventHandler <SerialDataEventArgs>(NewSerialDataRecieved); processData = new ProcessData(54); string[] portNames; portNames = serial.GetPortNames(); for (int i = 0; i < portNames.Length; i++) { UpdateStatus(this, new UpdateStatusEvent("Versuche mit " + portNames[i] + " zu verbinden")); serial.Connect(portNames[i]); serial.CallSensor(); Delay(300); if (processData.sensorAnswer) { UpdateStatus(this, new UpdateStatusEvent("Verbunden mit " + portNames[i])); firstPackage = true; break; } } if (processData.sensorAnswer) { serial.StartSensor(); connectDialog.Hide(); form1.Show(); } else { UpdateStatus(this, new UpdateStatusEvent("Kein Sensor gefunden")); UpdateStatus(this, new UpdateStatusEvent("Stellen Sie sicher, dass Bluetooth am Computer aktiviert ist und der Sensor eingeschaltet ist")); UpdateStatus(this, new UpdateStatusEvent("Schalten Sie den Sensor aus und wieder ein und versuchen Sie es erneut")); } } else { if (ShowDialog("Möchten Sie die Verbindung zum Sensor wirklich schließen?", "Verbindung schließen") == DialogResult.OK) { Disconnect(); } } //Enable/Disable Disconnect Timer form1.EnableTimer(processData.sensorAnswer); //Save Button aktivieren/deaktivieren form1.ChangeSaveButtonState(processData.sensorAnswer); //Connect Button anpassen form1.ChangeConnectButtonText(processData.sensorAnswer); //Activate Button form1.ChangeConnectButtonState(true); connectDialog.ChangeConnectButtonState(true); }
public void SetSerial(SerialCommunication serial) { _serial = serial; _serial.PressureTempCommunicationReceived += new SerialCommunication.ReceivePressureTempCommunicationFrame(_serial_PressureTempCommunicationReceived); _serial.GyroAccRawCommunicationReceived += new SerialCommunication.ReceiveGyroAccRawCommunicationFrame(_serial_GyroAccRawCommunicationReceived); _serial.GyroAccProcCommunicationReceived += new SerialCommunication.ReceiveGyroAccProcCommunicationFrame(_serial_GyroAccProcCommunicationReceived); _serial.AttitudeCommunicationReceived += new SerialCommunication.ReceiveAttitudeCommunicationFrame(_serial_AttitudeCommunicationReceived); }
public EasyConfig(SerialCommunication serial) : this() { this.serial = serial; serial.AllConfigCommunicationReceived += new SerialCommunication.ReceiveAllConfigCommunicationFrame(serial_AllConfigCommunicationReceived); serial.AttitudeCommunicationReceived += new SerialCommunication.ReceiveAttitudeCommunicationFrame(serial_AttitudeCommunicationReceived); serial.RcInputCommunicationReceived += new SerialCommunication.ReceiveRcInputCommunicationFrame(serial_RcInputCommunicationReceived); serial.ControlInfoCommunicationReceived += new SerialCommunication.ReceiveControlInfoCommunicationFrame(serial_ControlInfoCommunicationReceived); }
static public SerialCommunication getInstance() { if (m_Instance == null) { m_Instance = new SerialCommunication(); } return(m_Instance); }
public GraphForm(SerialCommunication serial) { _serial = serial; InitializeComponent(); graph1.SetSerial(serial); }
public KmlListener(SerialCommunication serial) { _smartThreadPool = new SmartThreadPool(); serial_comm = serial; serial.AttitudeCommunicationReceived += new SerialCommunication.ReceiveAttitudeCommunicationFrame(serial_AttitudeCommunicationReceived); serial.GpsBasicCommunicationReceived += new SerialCommunication.ReceiveGpsBasicCommunicationFrame(serial_GpsBasicCommunicationReceived); serial.PressureTempCommunicationReceived += new SerialCommunication.ReceivePressureTempCommunicationFrame(serial_PressureTempCommunicationReceived); serial.ControlInfoCommunicationReceived += new SerialCommunication.ReceiveControlInfoCommunicationFrame(serial_ControlInfoCommunicationReceived); }
public void Disconnect() { if (connected) { _serial.AllConfigCommunicationReceived += new SerialCommunication.ReceiveAllConfigCommunicationFrame(_serial_AllConfigCommunicationReceived); } _serial = null; connected = false; }
public void Connect(int baudrate, string portName) { serialCom = new SerialCommunication(portName, baudrate); serialCom.OpenSerialPort();// 打開串口 // 綁定方法觸發,監聽讀取串口 serialCom.SerialPortMessageEvent += SerialCom_SerialPortMessageEvent; // 綁定方法觸發,給串口發消息 serialCom.SerialPortSendMessageReportEvent += SerialCom_SerialPortSendMessageReportEvent; }
public void Connect(int baudrate, string portName, LidarType lidarType) { m_LidarType = lidarType; m_SerialCom = new SerialCommunication(portName, baudrate, lidarType); m_SerialCom.OpenSerialPort();// 打开串口 // 绑定方法触发,监听读取串口 m_SerialCom.SerialPortMessageEvent += SerialCom_SerialPortMessageEvent; // 绑定方法触发,给串口发消息 m_SerialCom.SerialPortSendMessageReportEvent += SerialCom_SerialPortSendMessageReportEvent; }
public void StartMainScene() { // Get the input from the text field string portNumber = comPortInput.text; // Open the required serial port SerialCommunication.SetSerialPortID(portNumber); // Load the main scene SceneManager.LoadScene("MainScene"); }
public void ThrowsExceptionOnNonExistingSerial() { Mock <ILibc> mock = new Mock <ILibc>(); mock.Setup(o => o.Open(It.IsAny <string>(), It.IsAny <Libc.OpenFlags>())).Returns(-1); SerialCommunication serial = new SerialCommunication(mock.Object); Assert.Throws <SerialNotFoundException>(() => serial.Open("dummy")); }
public void RunsWithExistingSerial() { Mock <ILibc> mock = new Mock <ILibc>(); mock.Setup(o => o.Open(It.IsAny <string>(), It.IsAny <Libc.OpenFlags>())).Returns(1); SerialCommunication serial = new SerialCommunication(mock.Object); Assert.DoesNotThrow(() => serial.Open("dummy")); }
public ConfigurationControl() { InitializeComponent(); _serial = null; _btn_burn.Enabled = false; _btn_default.Enabled = false; _btn_read.Enabled = false; _btn_reload.Enabled = false; _btn_write.Enabled = false; }
public void Connect(SerialCommunication serial) { this.serial = serial; _btn_read.Enabled = true; _btn_download.Enabled = true; _btn_format.Enabled = true; serial.DatalogTableCommunicationReceived += new SerialCommunication.ReceiveDatalogTableCommunicationFrame(ReceiveDatalogTable); serial.DatalogLineCommunicationReceived += new SerialCommunication.ReceiveDatalogLineCommunicationFrame(ReceiveDatalogLine); }
public void Connect(SerialCommunication serial) { _serial = serial; _btn_ge_server.Enabled = true; //_graphControl.SetSerial(serial); _serial.AttitudeCommunicationReceived += new SerialCommunication.ReceiveAttitudeCommunicationFrame(serial_AttitudeCommunicationReceived); _serial.PressureTempCommunicationReceived += new SerialCommunication.ReceivePressureTempCommunicationFrame(serial_PressureTempCommunicationReceived); _serial.GpsBasicCommunicationReceived += new SerialCommunication.ReceiveGpsBasicCommunicationFrame(serial_GpsBasicCommunicationReceived); _serial.ControlInfoCommunicationReceived += new SerialCommunication.ReceiveControlInfoCommunicationFrame(serial_ControlInfoCommunicationReceived); _graphControl.SetSerial(_serial); }
// Use this for initialization void Start() { lastRefPosition = lastPosition = new Vector3(0, 0, 0); lastRefRotation = lastRotation = Quaternion.identity; serialCtrl = GameObject.Find("RealCar").GetComponent <SerialCommunication> (); serialCtrl.open(); testKey = false; isLastRound = false; step = 0; count = 0; serialCtrl.median(); }
private RFBoxOpticalSensor() { this.serial = new SerialCommunication(); this.serial.END_OF_LINE = (char)13; this.serial.PortName = "COM15"; serial.PortConnected += new SerialDataPortEventHandler(serial_PortConnected); serial.DataReceived += new SerialDataReceivedEventHandler(serial_DataReceived); timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); disconnectedTimer.Elapsed += new ElapsedEventHandler(disconnectedTimer_Elapsed); connectingTimer.Elapsed += new ElapsedEventHandler(connectingTimer_Elapsed); disconnectedTimer.Start(); }
public void Disconnect() { timer1.Stop(); _serial = null; _btn_burn.Enabled = false; _btn_default.Enabled = false; _btn_read.Enabled = false; _btn_reload.Enabled = false; _btn_write.Enabled = false; configurationTabpage1.Disconnect(); }
/*! * Use serial as SerialCommunication and register our methods at the events */ public void Connect(SerialCommunication serial) { _serial = serial; _serial.GyroAccRawCommunicationReceived += new SerialCommunication_CSV.ReceiveGyroAccRawCommunicationFrame(ReceiveGyroAccRaw); _serial.GyroAccProcCommunicationReceived += new SerialCommunication_CSV.ReceiveGyroAccProcCommunicationFrame(ReceiveGyroAccProc); _serial.PressureTempCommunicationReceived += new SerialCommunication_CSV.ReceivePressureTempCommunicationFrame(ReceivePressureTemp); _serial.AllConfigCommunicationReceived += new SerialCommunication_CSV.ReceiveAllConfigCommunicationFrame(ReceiveAllConfig); _serial.RcInputCommunicationReceived += new SerialCommunication_CSV.ReceiveRcInputCommunicationFrame(ReceiveRcInput); _serial.GpsBasicCommunicationReceived += new SerialCommunication.ReceiveGpsBasicCommunicationFrame(ReceiveGpsBasic); _serial.DatalogTableCommunicationReceived += new SerialCommunication.ReceiveDatalogTableCommunicationFrame(ReceiveDatalogTable); _serial.DatalogLineCommunicationReceived += new SerialCommunication.ReceiveDatalogLineCommunicationFrame(ReceiveDatalogLine); }
private void buttonDisconnect_Click(object sender, EventArgs e) { if (serialComm != null) { serialComm.Dispose(); serialComm = null; buttonConnect.Enabled = true; buttonDisconnect.Enabled = false; buttonRequest.Enabled = false; checkAutorequest.Enabled = false; } }
public void Connect(SerialCommunication serial) { _serial = serial; _btn_burn.Enabled = true; _btn_default.Enabled = true; _btn_read.Enabled = true; _btn_reload.Enabled = true; _btn_write.Enabled = true; configurationTabpage1.Connect(serial); timer1.Start(); }
//**********************************************************************************// // INITIAL SETUP // // prepare the initial information for capsule collider, physics materials, etc... // //**********************************************************************************// public void InitialSetup() { animator = GetComponent<Animator>(); shootables = new List<Transform>(); // better sync of animations like quickTurn180 animator.updateMode = AnimatorUpdateMode.AnimatePhysics; communication = new SerialCommunication(); tpCamera = TPCamera.instance; CollectShootableBodyParts(transform); if (hud == null) Debug.Log("Missing HUDController, please assign on ThirdPersonController"); // prevents the collider from slipping on ramps frictionPhysics = new PhysicMaterial(); frictionPhysics.name = "frictionPhysics"; frictionPhysics.staticFriction = 0.6f; frictionPhysics.dynamicFriction = 0.6f; // default physics defaultPhysics = new PhysicMaterial(); defaultPhysics.name = "defaultPhysics"; defaultPhysics.staticFriction = 0f; defaultPhysics.dynamicFriction = 0f; // rigidbody info _rigidbody = GetComponent<Rigidbody> (); // capsule collider capsuleCollider = GetComponent<CapsuleCollider>(); // save your collider preferences colliderCenter = GetComponent<CapsuleCollider>().center; colliderRadius = GetComponent<CapsuleCollider>().radius; colliderHeight = GetComponent<CapsuleCollider>().height; CreateBonesToCurve(); currentHealth = startingHealth; currentStamina = startingStamina; if(hud == null) return; hud.damageImage.color = new Color(0f, 0f, 0f, 0f); }