private void UpdateStatus() { // Make sure someone is listening to event if (newValueMotor == null) return; MotorEventArgs args = new MotorEventArgs(trackBar1.Value, cbSentido.Checked, cbFreno.Checked, Decimal.ToInt32(numericUpDown1.Value)); newValueMotor(this, args); }
void motor_ctrl1_newValueMotor(object sender, MotorEventArgs e) { if (serialPort1.IsOpen) { mens3.CMD = 0xA1; mens3.nDatos = 4; mens3.Datos[0] = (byte)e.motorData.id; mens3.Datos[1] = e.motorData.Sentido ? (byte)1 : (byte)0; mens3.Datos[2] = e.motorData.freno ? (byte)1 : (byte)0; mens3.Datos[3] = (byte)e.motorData.velocidad; } }