コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        private void FmMain_Load(Object sender, EventArgs e)
        {
            cbDirection1.SelectedIndex = 0;
            cbDirection2.SelectedIndex = 0;

            FManager = new wclBluetoothManager();

            FWatcher             = new wclWeDoWatcher();
            FWatcher.OnHubFound += FWatcher_OnHubFound;

            FHub                     = new wclWeDoHub();
            FHub.OnConnected        += FHub_OnConnected;
            FHub.OnDisconnected     += FHub_OnDisconnected;
            FHub.OnDeviceAttached   += FHub_OnDeviceAttached;
            FHub.OnDeviceDetached   += FHub_OnDeviceDetached;
            FHub.OnHighCurrentAlert += FHub_OnHighCurrentAlert;
            FHub.OnLowVoltageAlert  += FHub_OnLowVoltageAlert;

            FMotor1  = null;
            FMotor2  = null;
            FCurrent = null;
            FVoltage = null;
        }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
ファイル: main.cs プロジェクト: leuher/WeDo
        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);
                }
            }
        }
コード例 #5
0
ファイル: main.cs プロジェクト: leuher/WeDo
 private void UpdateVoltage(wclWeDoVoltageSensor Sensor)
 {
     UpdateDeviceInfo(laVoltageVersion, laVoltageDeviceType, laVoltageConnectionId, Sensor);
     laVoltage.Text = Sensor.Voltage.ToString() + " mV";
 }