Exemple #1
0
        private void ConnectEvents(wclWeDoIo Device)
        {
            switch (Device.DeviceType)
            {
            case wclWeDoIoDeviceType.iodCurrentSensor:
                (Device as wclWeDoCurrentSensor).OnCurrentChanged += FmMain_OnCurrentChanged;
                break;

            case wclWeDoIoDeviceType.iodVoltageSensor:
                (Device as wclWeDoVoltageSensor).OnVoltageChanged += FmMain_OnVoltageChanged;
                break;

            case wclWeDoIoDeviceType.iodRgb:
                wclWeDoRgbLight Rgb = (Device as wclWeDoRgbLight);
                Rgb.OnColorChanged += FmMain_OnColorChanged;
                Rgb.OnModeChanged  += FmMain_OnModeChanged;
                break;

            case wclWeDoIoDeviceType.iodMotionSensor:
                wclWeDoMotionSensor Motion = (Device as wclWeDoMotionSensor);
                Motion.OnCountChanged    += FmMain_OnCountChanged;
                Motion.OnDistanceChanged += FmMain_OnDistanceChanged;
                Motion.OnModeChanged     += FmMain_OnMotionModeChanged;
                break;

            case wclWeDoIoDeviceType.iodTiltSensor:
                wclWeDoTiltSensor Tilt = (Device as wclWeDoTiltSensor);
                Tilt.OnModeChanged      += Tilt_OnModeChanged;
                Tilt.OnDirectionChanged += Tilt_OnDirectionChanged;
                Tilt.OnCrashChanged     += Tilt_OnCrashChanged;
                Tilt.OnAngleChanged     += Tilt_OnAngleChanged;
                break;
            }
        }
Exemple #2
0
        private void Hub_OnDeviceDetached(object Sender, wclWeDoIo Device)
        {
            wclWeDoHub Hub = GetHub();

            if (Hub != null && Hub.Address == Device.Hub.Address)
            {
                switch (Device.DeviceType)
                {
                case wclWeDoIoDeviceType.iodCurrentSensor:
                    RemovePage(tsCurrent);
                    break;

                case wclWeDoIoDeviceType.iodVoltageSensor:
                    RemovePage(tsVoltage);
                    break;

                case wclWeDoIoDeviceType.iodRgb:
                    RemovePage(tsRgb);
                    break;

                case wclWeDoIoDeviceType.iodPiezo:
                    RemovePage(tsPiezo);
                    break;

                case wclWeDoIoDeviceType.iodMotionSensor:
                    if (Device.PortId == 0)
                    {
                        RemovePage(tsMotion1);
                    }
                    else
                    {
                        RemovePage(tsMotion2);
                    }
                    break;

                case wclWeDoIoDeviceType.iodTiltSensor:
                    if (Device.PortId == 0)
                    {
                        RemovePage(tsTilt1);
                    }
                    else
                    {
                        RemovePage(tsTilt2);
                    }
                    break;

                case wclWeDoIoDeviceType.iodMotor:
                    if (Device.PortId == 0)
                    {
                        RemovePage(tsMotor1);
                    }
                    else
                    {
                        RemovePage(tsMotor2);
                    }
                    break;
                }
            }
        }
Exemple #3
0
 private void FHub_OnDeviceDetached(Object Sender, wclWeDoIo Device)
 {
     if (Device.DeviceType == wclWeDoIoDeviceType.iodPiezo)
     {
         FPiezo = null;
         EnablePlay(false);
     }
 }
Exemple #4
0
 private void FHub_OnDeviceAttached(Object Sender, wclWeDoIo Device)
 {
     if (Device.DeviceType == wclWeDoIoDeviceType.iodPiezo)
     {
         FPiezo = (wclWeDoPiezo)Device;
         EnablePlay(true);
     }
 }
Exemple #5
0
 private void FHub_OnDeviceDetached(Object Sender, wclWeDoIo Device)
 {
     if (Device.DeviceType == wclWeDoIoDeviceType.iodRgb)
     {
         FRgb = null;
         EnableSetColors(false);
     }
 }
Exemple #6
0
 private void FHub_OnDeviceDetached(Object Sender, wclWeDoIo Device)
 {
     if (Device.DeviceType == wclWeDoIoDeviceType.iodTiltSensor && FTilt != null && Device.ConnectionId == FTilt.ConnectionId)
     {
         FTilt = null;
         EnableControl(false);
     }
 }
Exemple #7
0
        private void FHub_OnDeviceAttached(Object Sender, wclWeDoIo Device)
        {
            ListViewItem Item = lvAttachedDevices.Items.Add(Device.ConnectionId.ToString());

            Item.SubItems.Add(Device.DeviceType.ToString());
            Item.SubItems.Add(Device.FirmwareVersion.ToString());
            Item.SubItems.Add(Device.HardwareVersion.ToString());
            Item.SubItems.Add(Device.Internal.ToString());
            Item.SubItems.Add(Device.PortId.ToString());
        }
Exemple #8
0
 private void FHub_OnDeviceDetached(Object Sender, wclWeDoIo Device)
 {
     foreach (ListViewItem Item in lvAttachedDevices.Items)
     {
         if (Item.Text == Device.ConnectionId.ToString())
         {
             lvAttachedDevices.Items.Remove(Item);
             break;
         }
     }
 }
Exemple #9
0
        private void FHub_OnDeviceAttached(Object Sender, wclWeDoIo Device)
        {
            if (Device.DeviceType == wclWeDoIoDeviceType.iodRgb)
            {
                FRgb = (wclWeDoRgbLight)Device;
                FRgb.OnColorChanged += FRgb_OnColorChanged;
                FRgb.OnModeChanged  += FRgb_OnModeChanged;

                EnableSetColors(true);
                EnableColorControls();
            }
        }
Exemple #10
0
        private void FHub_OnDeviceDetached(object Sender, wclWeDoIo Device)
        {
            if (Device.DeviceType == wclWeDoIoDeviceType.iodColorSensor && FColor != null && Device.ConnectionId == FColor.ConnectionId)
            {
                FColor = null;
                EnableControl(false);
            }

            if (Device.DeviceType == wclWeDoIoDeviceType.iodRgb)
            {
                FRgb = null;
            }
        }
Exemple #11
0
 private void FHub_OnDeviceAttached(Object Sender, wclWeDoIo Device)
 {
     if (FMotion == null)
     {
         if (Device.DeviceType == wclWeDoIoDeviceType.iodMotionSensor)
         {
             FMotion = (wclWeDoMotionSensor)Device;
             FMotion.OnCountChanged    += FMotion_OnCountChanged;
             FMotion.OnDistanceChanged += FMotion_OnDistanceChanged;
             FMotion.OnModeChanged     += FMotion_OnModeChanged;
             EnableControl(true);
         }
     }
 }
Exemple #12
0
 private void FHub_OnDeviceAttached(Object Sender, wclWeDoIo Device)
 {
     if (FTilt == null)
     {
         if (Device.DeviceType == wclWeDoIoDeviceType.iodTiltSensor)
         {
             FTilt = (wclWeDoTiltSensor)Device;
             FTilt.OnAngleChanged     += FTilt_OnAngleChanged;
             FTilt.OnCrashChanged     += FTilt_OnCrashChanged;
             FTilt.OnDirectionChanged += FTilt_OnDirectionChanged;
             FTilt.OnModeChanged      += FTilt_OnModeChanged;
             EnableControl(true);
         }
     }
 }
Exemple #13
0
        private void FHub_OnDeviceAttached(object Sender, wclWeDoIo Device)
        {
            if (FColor == null)
            {
                if (Device.DeviceType == wclWeDoIoDeviceType.iodColorSensor)
                {
                    FColor = (wclWeDoColorSensor)Device;
                    FColor.OnColorDetected += FColor_OnColorDetected;
                    EnableControl(true);
                }
            }

            if (Device.DeviceType == wclWeDoIoDeviceType.iodRgb)
            {
                FRgb = (wclWeDoRgbLight)Device;
            }
        }
Exemple #14
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;
                }
            }
        }
Exemple #15
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;
     }
 }
Exemple #16
0
 private void UpdateDeviceInfo(Label Version, Label Internal, Label ConnectionId, wclWeDoIo Device)
 {
     Version.Text = "Firmware: " +
                    Device.FirmwareVersion.MajorVersion.ToString() + "." +
                    Device.FirmwareVersion.MinorVersion.ToString() + "." +
                    Device.FirmwareVersion.BuildNumber.ToString() + "." +
                    Device.FirmwareVersion.BugFixVersion.ToString() +
                    "  Hardware: " +
                    Device.HardwareVersion.MajorVersion.ToString() + "." +
                    Device.HardwareVersion.MinorVersion.ToString() + "." +
                    Device.HardwareVersion.BuildNumber.ToString() + "." +
                    Device.HardwareVersion.BugFixVersion.ToString();
     if (Device.Internal)
     {
         Internal.Text = "Internal";
     }
     else
     {
         Internal.Text = "External";
     }
     ConnectionId.Text = "Connection ID: " + Device.ConnectionId.ToString() +
                         "  Port ID: " + Device.PortId.ToString();
 }
Exemple #17
0
        private void Hub_OnDeviceAttached(object Sender, wclWeDoIo Device)
        {
            ConnectEvents(Device);

            wclWeDoHub Hub = GetHub();

            if (Hub != null && Hub.Address == Device.Hub.Address)
            {
                switch (Device.DeviceType)
                {
                case wclWeDoIoDeviceType.iodCurrentSensor:
                    AddPage(tsCurrent);
                    UpdateCurrent(Device as wclWeDoCurrentSensor);
                    break;

                case wclWeDoIoDeviceType.iodVoltageSensor:
                    AddPage(tsVoltage);
                    UpdateVoltage(Device as wclWeDoVoltageSensor);
                    break;

                case wclWeDoIoDeviceType.iodRgb:
                    AddPage(tsRgb);
                    UpdateRgb(Device as wclWeDoRgbLight);
                    break;

                case wclWeDoIoDeviceType.iodPiezo:
                    AddPage(tsPiezo);
                    UpdatePiezo(Device as wclWeDoPiezo);
                    break;

                case wclWeDoIoDeviceType.iodMotionSensor:
                    if (Device.PortId == 0)
                    {
                        AddPage(tsMotion1);
                    }
                    else
                    {
                        AddPage(tsMotion2);
                    }
                    UpdateMotion(Device as wclWeDoMotionSensor);
                    break;

                case wclWeDoIoDeviceType.iodTiltSensor:
                    if (Device.PortId == 0)
                    {
                        AddPage(tsTilt1);
                    }
                    else
                    {
                        AddPage(tsTilt2);
                    }
                    UpdateTilt(Device as wclWeDoTiltSensor);
                    break;

                case wclWeDoIoDeviceType.iodMotor:
                    if (Device.PortId == 0)
                    {
                        AddPage(tsMotor1);
                    }
                    else
                    {
                        AddPage(tsMotor2);
                    }
                    UpdateMotor(Device as wclWeDoMotor);
                    break;
                }
            }
        }