private void StartMotor(Byte Port, ComboBox Direction, TextBox Power) { wclWeDoMotor Motor = GetMotor(Port); if (Motor != null) { wclWeDoMotorDirection Dir; switch (Direction.SelectedIndex) { case 0: Dir = wclWeDoMotorDirection.mdRight; break; case 1: Dir = wclWeDoMotorDirection.mdLeft; break; default: Dir = wclWeDoMotorDirection.mdUnknown; break; } Int32 Res = Motor.Run(Dir, Convert.ToByte(Power.Text)); if (Res != wclErrors.WCL_E_SUCCESS) { MessageBox.Show("Start motor failed: 0x" + Res.ToString("X8")); } } }
private void UpdateMotor(wclWeDoMotor Sensor) { if (Sensor.PortId == 0) { UpdateDeviceInfo(laMotorVersion1, laMotorDeviceType1, laMotorConnectionId1, Sensor); } else { UpdateDeviceInfo(laMotorVersion2, laMotorDeviceType2, laMotorConnectionId2, Sensor); } }
private void DriftMotor(Byte Port) { wclWeDoMotor Motor = GetMotor(Port); if (Motor != null) { Int32 Res = Motor.Drift(); if (Res != wclErrors.WCL_E_SUCCESS) { MessageBox.Show("Drift failed; 0x" + Res.ToString("X8")); } } }
private void FHub_OnDeviceAttached(Object Sender, wclWeDoIo Device) { if (Device.DeviceType == wclWeDoIoDeviceType.iodMotor) { if (FMotor1 == null) { { FMotor1 = (wclWeDoMotor)Device; EnablePlay1(true); } } else { if (FMotor2 == null) { { FMotor2 = (wclWeDoMotor)Device; EnablePlay2(true); } } } } if (FCurrent == null) { if (Device.DeviceType == wclWeDoIoDeviceType.iodCurrentSensor) { FCurrent = (wclWeDoCurrentSensor)Device; FCurrent.OnCurrentChanged += FCurrent_OnCurrentChanged; } } if (FVoltage == null) { if (Device.DeviceType == wclWeDoIoDeviceType.iodVoltageSensor) { FVoltage = (wclWeDoVoltageSensor)Device; FVoltage.OnVoltageChanged += FVoltage_OnVoltageChanged; } } }
private void FHub_OnDeviceDetached(Object Sender, wclWeDoIo Device) { if (Device.DeviceType == wclWeDoIoDeviceType.iodMotor) { if (FMotor1 != null && FMotor1.ConnectionId == Device.ConnectionId) { FMotor1 = null; EnablePlay1(false); } if (FMotor2 != null && FMotor2.ConnectionId == Device.ConnectionId) { FMotor2 = null; EnablePlay2(false); } } if (Device.DeviceType == wclWeDoIoDeviceType.iodCurrentSensor) { FCurrent = null; } if (Device.DeviceType == wclWeDoIoDeviceType.iodVoltageSensor) { FVoltage = null; } }
private void UpdateTabs() { wclWeDoHub Hub = GetHub(); if (Hub == null) { RemoveTabs(); } else { AddPage(tsHubInfo); UpdateHubInfo(Hub); wclWeDoCurrentSensor Current = FRobot.GetCurrentSensor(Hub); if (Current != null && Current.Attached) { AddPage(tsCurrent); UpdateCurrent(Current); } wclWeDoVoltageSensor Voltage = FRobot.GetVoltageSensor(Hub); if (Voltage != null && Voltage.Attached) { AddPage(tsVoltage); UpdateVoltage(Voltage); } wclWeDoRgbLight Rgb = FRobot.GetRgbDevice(Hub); if (Rgb != null && Rgb.Attached) { AddPage(tsRgb); UpdateRgb(Rgb); } wclWeDoPiezo Piezo = FRobot.GetPiezoDevice(Hub); if (Piezo != null && Piezo.Attached) { AddPage(tsPiezo); UpdatePiezo(Piezo); } wclWeDoMotionSensor Motion = GetMotionSensor(0); if (Motion != null && Motion.Attached) { AddPage(tsMotion1); UpdateMotion(Motion); } Motion = GetMotionSensor(1); if (Motion != null && Motion.Attached) { AddPage(tsMotion2); UpdateMotion(Motion); } wclWeDoTiltSensor Tilt = GetTiltSensor(0); if (Tilt != null && Tilt.Attached) { AddPage(tsTilt1); UpdateTilt(Tilt); } Tilt = GetTiltSensor(1); if (Tilt != null && Tilt.Attached) { AddPage(tsTilt2); UpdateTilt(Tilt); } wclWeDoMotor Motor = GetMotor(0); if (Motor != null && Motor.Attached) { AddPage(tsMotor1); UpdateMotor(Motor); } Motor = GetMotor(1); if (Motor != null && Motor.Attached) { AddPage(tsMotor2); UpdateMotor(Motor); } } }