public void DeviceListEqualityTest()
        {
            var dateTimeOffset = DateTimeOffset.Now;

            var left = new DeviceList
            {
                DeviceId = "id",
                LastApp = "lastapp",
                LastHeard = dateTimeOffset,
                Name = "name",
                LastIpAddress = "127.0.0.1",
                ProductId = 6,
                Connected = true
            };

            var right = new DeviceList
            {
                DeviceId = "id",
                LastApp = "lastapp",
                LastHeard = dateTimeOffset,
                Name = "name",
                LastIpAddress = "127.0.0.1",
                ProductId = 6,
                Connected = true
            };

            Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
            Assert.AreEqual(left, right);
        }
Esempio n. 2
0
        public bool Initialize()
        {
            IDeviceList list = new DeviceList();
              list.Scan();
              this.logger.Debug("Found {0} devices", list.Count());

              this.device = list.FirstOrDefault();
              this.logger.Debug("Selected device: {0}", (this.device as Device)?.DevicePath ?? "None");

              return this.device != null;
        }
Esempio n. 3
0
        public static IDevice GetDevice()
        {
            IDeviceList list = new DeviceList();
            list.Scan();

            if (list.Count() == 0)
            {
                throw new Exception("No Luxafor device found");
            }

            return list.First();
        }
Esempio n. 4
0
    public Configure(DeviceList deviceList)
    {
      InitializeComponent();

      _diListener = new DirectInputListener();
      _diListener.Delay = 150;

      foreach (DeviceInstance di in deviceList)
      {
        ListViewItem item = new ListViewItem(
          new string[] {di.InstanceName, di.ProductName}
          );

        item.Tag = di.InstanceGuid.ToString();

        listViewDevices.Items.Add(item);
      }
    }
Esempio n. 5
0
        public void MergeFrom(ServiceReply other)
        {
            if (other == null)
            {
                return;
            }
            switch (other.TypeCase)
            {
            case TypeOneofCase.Success:
                if (Success == null)
                {
                    Success = new global::Ubii.General.Success();
                }
                Success.MergeFrom(other.Success);
                break;

            case TypeOneofCase.Error:
                if (Error == null)
                {
                    Error = new global::Ubii.General.Error();
                }
                Error.MergeFrom(other.Error);
                break;

            case TypeOneofCase.Client:
                if (Client == null)
                {
                    Client = new global::Ubii.Clients.Client();
                }
                Client.MergeFrom(other.Client);
                break;

            case TypeOneofCase.Device:
                if (Device == null)
                {
                    Device = new global::Ubii.Devices.Device();
                }
                Device.MergeFrom(other.Device);
                break;

            case TypeOneofCase.Server:
                if (Server == null)
                {
                    Server = new global::Ubii.Servers.Server();
                }
                Server.MergeFrom(other.Server);
                break;

            case TypeOneofCase.Session:
                if (Session == null)
                {
                    Session = new global::Ubii.Sessions.Session();
                }
                Session.MergeFrom(other.Session);
                break;

            case TypeOneofCase.SessionList:
                if (SessionList == null)
                {
                    SessionList = new global::Ubii.Sessions.SessionList();
                }
                SessionList.MergeFrom(other.SessionList);
                break;

            case TypeOneofCase.Interaction:
                if (Interaction == null)
                {
                    Interaction = new global::Ubii.Interactions.Interaction();
                }
                Interaction.MergeFrom(other.Interaction);
                break;

            case TypeOneofCase.InteractionList:
                if (InteractionList == null)
                {
                    InteractionList = new global::Ubii.Interactions.InteractionList();
                }
                InteractionList.MergeFrom(other.InteractionList);
                break;

            case TypeOneofCase.StringList:
                if (StringList == null)
                {
                    StringList = new global::Ubii.DataStructure.StringList();
                }
                StringList.MergeFrom(other.StringList);
                break;

            case TypeOneofCase.TopicMux:
                if (TopicMux == null)
                {
                    TopicMux = new global::Ubii.Devices.TopicMux();
                }
                TopicMux.MergeFrom(other.TopicMux);
                break;

            case TypeOneofCase.TopicMuxList:
                if (TopicMuxList == null)
                {
                    TopicMuxList = new global::Ubii.Devices.TopicMuxList();
                }
                TopicMuxList.MergeFrom(other.TopicMuxList);
                break;

            case TypeOneofCase.TopicDemux:
                if (TopicDemux == null)
                {
                    TopicDemux = new global::Ubii.Devices.TopicDemux();
                }
                TopicDemux.MergeFrom(other.TopicDemux);
                break;

            case TypeOneofCase.TopicDemuxList:
                if (TopicDemuxList == null)
                {
                    TopicDemuxList = new global::Ubii.Devices.TopicDemuxList();
                }
                TopicDemuxList.MergeFrom(other.TopicDemuxList);
                break;

            case TypeOneofCase.ClientList:
                if (ClientList == null)
                {
                    ClientList = new global::Ubii.Clients.ClientList();
                }
                ClientList.MergeFrom(other.ClientList);
                break;

            case TypeOneofCase.DeviceList:
                if (DeviceList == null)
                {
                    DeviceList = new global::Ubii.Devices.DeviceList();
                }
                DeviceList.MergeFrom(other.DeviceList);
                break;

            case TypeOneofCase.Service:
                if (Service == null)
                {
                    Service = new global::Ubii.Services.Service();
                }
                Service.MergeFrom(other.Service);
                break;

            case TypeOneofCase.ServiceList:
                if (ServiceList == null)
                {
                    ServiceList = new global::Ubii.Services.ServiceList();
                }
                ServiceList.MergeFrom(other.ServiceList);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
    /// <summary>
    /// Stop the IR Server plugin.
    /// </summary>
    public override void Stop()
    {
      if (_diListener != null)
      {
        _diListener.DeInitDevice();
        _diListener.StopListener();

        _diListener.OnStateChange -= diListener_OnStateChange;
        _diListener = null;
      }

      _deviceList = null;
    }
        /// <summary>
        /// Acquire the named joystick. You can find this joystick through the <see cref="FindJoysticks"/> method.
        /// </summary>
        /// <param name="name">Name of the joystick.</param>
        /// <returns>The success of the connection.</returns>
        public bool AcquireJoystick(string name)
        {
            avaAxis.Clear();
            try
            {
                DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
                int        i     = 0;
                bool       found = false;
                // loop through the devices.
                foreach (DeviceInstance deviceInstance in gameControllerList)
                {
                    if (deviceInstance.InstanceName == name)
                    {
                        found = true;
                        // create a device from this controller so we can retrieve info.
                        joystickDevice = new Device(deviceInstance.InstanceGuid);
                        //joystickDevice.SetCooperativeLevel(hWnd,
                        //    CooperativeLevelFlags.Background |
                        //    CooperativeLevelFlags.NonExclusive);
                        break;
                    }

                    i++;
                }

                if (!found)
                {
                    return(false);
                }

                // Tell DirectX that this is a Joystick.
                joystickDevice.SetDataFormat(DeviceDataFormat.Joystick);

                // Finally, acquire the device.
                joystickDevice.Acquire();

                // How many axes?
                // Find the capabilities of the joystick
                DeviceCaps cps = joystickDevice.Caps;
                ButtonCount = cps.NumberButtons;

                if (joystickDevice.CurrentJoystickState.X != 0)
                {
                    avaAxis.Add("x");
                }
                if (joystickDevice.CurrentJoystickState.Y != 0)
                {
                    avaAxis.Add("y");
                }
                if (joystickDevice.CurrentJoystickState.Z != 0)
                {
                    avaAxis.Add("z");
                }
                if (joystickDevice.CurrentJoystickState.Rx != 0)
                {
                    avaAxis.Add("rx");
                }
                if (joystickDevice.CurrentJoystickState.Ry != 0)
                {
                    avaAxis.Add("ry");
                }
                if (joystickDevice.CurrentJoystickState.Rz != 0)
                {
                    avaAxis.Add("rz");
                }
                if (joystickDevice.CurrentJoystickState.GetSlider()[0] != 0)
                {
                    avaAxis.Add("slider1");
                }
                if (joystickDevice.CurrentJoystickState.GetSlider()[1] != 0)
                {
                    avaAxis.Add("slider2");
                }

                availableAxis = avaAxis.ToArray();

                Debug.WriteLine("Joystick Axis: " + cps.NumberAxes);
                //Debug.WriteLine(joystickDevice.CurrentJoystickState.ToString());
                //Debug.WriteLine(joystickDevice.CurrentJoystickState.GetSlider()[0].ToString()+" "+
                //    joystickDevice.CurrentJoystickState.GetSlider()[1].ToString());

                axisCount = cps.NumberAxes;

                UpdateStatus();
            }
            catch (Exception err)
            {
                Debug.WriteLine("FindJoysticks()");
                Debug.WriteLine(err.Message);
                Debug.WriteLine(err.StackTrace);
                //throw err;
                return(false);
            }

            return(true);
        }
Esempio n. 8
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Topic.Length != 0)
            {
                hash ^= Topic.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Client)
            {
                hash ^= Client.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Device)
            {
                hash ^= Device.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicSubscription)
            {
                hash ^= TopicSubscription.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Session)
            {
                hash ^= Session.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.SessionList)
            {
                hash ^= SessionList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Interaction)
            {
                hash ^= Interaction.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.InteractionList)
            {
                hash ^= InteractionList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicMux)
            {
                hash ^= TopicMux.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicMuxList)
            {
                hash ^= TopicMuxList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicDemux)
            {
                hash ^= TopicDemux.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicDemuxList)
            {
                hash ^= TopicDemuxList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.ClientList)
            {
                hash ^= ClientList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.DeviceList)
            {
                hash ^= DeviceList.GetHashCode();
            }
            hash ^= (int)typeCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
 public DeviceCheckList(DeviceList deviceList)
 {
     AddRange(deviceList);
 }
Esempio n. 10
0
 public void UpdateAndReloadConfig(DeviceList devices)
 {
     WriteUpdatedConfigFile(devices);
     LoadConfig();
 }
Esempio n. 11
0
 public DeviceListViewModel()
 {
     DeviceList = new DeviceList();
     Devices    = DeviceList.FilterDevices;
 }
Esempio n. 12
0
        // 機能を構成するコンポーネントをたどる関数
        // 機能を構成するコンポーネントのリストをたどり
        // 機能を構成するコンポーネントと通信の情報のリストを返す
        // やっていることは幅優先探索
        internal List <XDocument> GetProcesstPath(List <Component> FunctionComposedComponentList)
        {
            //FunctionComposedComponentList.ForEach(x => MessageBox.Show(x.Name));

            var CurrentComponent = FunctionComposedComponentList.Pop();
            var CurrentDevice    = GetParentDevice(CurrentComponent);

            // MessageBox.Show(CurrentComponent.Name);

            // ComponentXMLにDeviceXMLを追加したxmlを生成
            // XMLを結合させるやり方がわからないので、文字列にして連結させている
            var CurrentComponentAndDeviceXDocumentStringBuilder = new StringBuilder()
                                                                  .Append("<process>")
                                                                  .Append("<component>").Append(CurrentComponent.xdocument).Append("</component>")
                                                                  .Append("<device>").Append(CurrentDevice.xdocument).Append("</device>")
                                                                  .Append("</process>");
            var CurrentComponentAndDeviceXDocument = CurrentComponentAndDeviceXDocumentStringBuilder.ToString().ToXDocument();

            FunctionComposedXDocumentList.Add(CurrentComponentAndDeviceXDocument);

            // 探索オブジェクトがなくなったら終了
            if (!FunctionComposedComponentList.Any())
            {
                var result = new List <XDocument>(FunctionComposedXDocumentList);
                FunctionComposedXDocumentList.Clear();
                return(result);
            }

            var NextComponent = FunctionComposedComponentList.First();

            // 探索ステップ1
            // 同一ルートデバイスに目的のコンポーネントが存在するか探索
            if (GetRootDevice(CurrentComponent) == GetRootDevice(NextComponent))
            {
                return(GetProcesstPath(FunctionComposedComponentList));
            }


            // 探索ステップ2
            // 目的のコンポーネントが別のデバイス上に存在している場合
            var SearchedConnectorList = new List <Connector>(GetRootDevice(CurrentDevice).ConnectorList);

            // 現在のデバイスとそのデバイスからの経路のXMLをもったDictionaryを作成
            // 初期要素は現在のデバイスとそのXML
            var DeviceAndPathXDocumentDictionary = new Dictionary <Device, List <XDocument> >()
            {
                { GetRootDevice(CurrentDevice), new List <XDocument>() }
            };

            while (SearchedConnectorList.Any())
            {
                var connector          = SearchedConnectorList.Pop();
                var connectorXDocument = connector.Notes.ToXDocument();
                var NextDevice         = DeviceList.Single(Device => Device.ID == connector.SupplierID);
                var Movement           = IsMovement(Repository, CurrentDevice, NextDevice);
                var ConnectorXDocumentStringBuilder = new StringBuilder()
                                                      .Append("<communication>")
                                                      .Append("<connector>")
                                                      .Append(connectorXDocument)
                                                      .Append("<movement>").Append(Movement).Append("</movement>")
                                                      .Append("</connector>")
                                                      .Append("<component>").Append(CurrentComponent.xdocument).Append("</component>")
                                                      .Append("</communication>");
                connectorXDocument = ConnectorXDocumentStringBuilder.ToString().ToXDocument();

                CurrentDevice = DeviceList.Single(Device => Device.ID == connector.ClientID);


                // 期待するSupplierIdとClientIdが逆だった場合に、これらを入れ替える
                if (!DeviceAndPathXDocumentDictionary.ContainsKey(CurrentDevice))
                {
                    var tmp = CurrentDevice;
                    CurrentDevice = NextDevice;
                    NextDevice    = tmp;
                }

                // 現在のルートデバイスから各ルートデバイスへの通信の経路XMLをもつリストを取得
                var ConnectorPathXDocumentList = new List <XDocument>(DeviceAndPathXDocumentDictionary[CurrentDevice])
                {
                    connectorXDocument
                };
                DeviceAndPathXDocumentDictionary.Add(NextDevice, ConnectorPathXDocumentList);

                // 探索したデバイスが目的のデバイスの場合、通信経路のXMLパスを経路情報に格納して再帰
                if (NextDevice == GetRootDevice(NextComponent))
                {
                    ConnectorPathXDocumentList.ForEach(ConnectorPathXDocument => FunctionComposedXDocumentList.Add(ConnectorPathXDocument));
                    return(GetProcesstPath(FunctionComposedComponentList));
                }

                // 探索したデバイスが目的のデバイスでなかった場合、探索したデバイスの他の接続情報を取得
                else if (NextDevice.ConnectorList.Count() > 1)
                {
                    NextDevice.ConnectorList.Where(Connector => Connector.Name != connector.Name)
                    .ToList()
                    .ForEach(Connector => SearchedConnectorList.Add(Connector));
                }
            }
            return(null);
        }
        public void TestDeviceListCmd()
        {
            var msg = new DeviceList(new[]
            {
                new DeviceMessageInfo(2, "testDev0", new Dictionary <string, MessageAttributes>
                {
                    { "StopDeviceCmd", new MessageAttributes() },
                    { "VibrateCmd", new MessageAttributes()
                      {
                          FeatureCount = 1
                      } },
                }),
                new DeviceMessageInfo(5, "testDev1", new Dictionary <string, MessageAttributes>
                {
                    { "StopDeviceCmd", new MessageAttributes() },
                    { "RotateCmd", new MessageAttributes()
                      {
                          FeatureCount = 2
                      } },
                }),
            }, 6);

            Assert.AreEqual(6, msg.Id);
            Assert.AreEqual(2, msg.Devices.Length);
            Assert.AreEqual("testDev0", msg.Devices[0].DeviceName);
            Assert.AreEqual(2, msg.Devices[0].DeviceIndex);
            Assert.AreEqual(2, msg.Devices[0].DeviceMessages.Count);
            Assert.Contains("StopDeviceCmd", msg.Devices[0].DeviceMessages.Keys);
            Assert.Null(msg.Devices[0].DeviceMessages["StopDeviceCmd"].FeatureCount);
            Assert.Contains("VibrateCmd", msg.Devices[0].DeviceMessages.Keys);
            Assert.AreEqual(1, msg.Devices[0].DeviceMessages["VibrateCmd"].FeatureCount);
            Assert.AreEqual("testDev1", msg.Devices[1].DeviceName);
            Assert.AreEqual(5, msg.Devices[1].DeviceIndex);
            Assert.AreEqual(2, msg.Devices[1].DeviceMessages.Count);
            Assert.Contains("StopDeviceCmd", msg.Devices[1].DeviceMessages.Keys);
            Assert.Null(msg.Devices[1].DeviceMessages["StopDeviceCmd"].FeatureCount);
            Assert.Contains("RotateCmd", msg.Devices[1].DeviceMessages.Keys);
            Assert.AreEqual(2, msg.Devices[1].DeviceMessages["RotateCmd"].FeatureCount);

            var str1 = _parser.Serialize(msg, 1);

            Assert.AreEqual(
                "[{\"DeviceList\":{\"Devices\":[{\"DeviceName\":\"testDev0\",\"DeviceIndex\":2,\"DeviceMessages\":{\"StopDeviceCmd\":{},\"VibrateCmd\":{\"FeatureCount\":1}}},{\"DeviceName\":\"testDev1\",\"DeviceIndex\":5,\"DeviceMessages\":{\"StopDeviceCmd\":{},\"RotateCmd\":{\"FeatureCount\":2}}}],\"Id\":6}}]",
                str1);

            var msgs = _parser.Deserialize(str1);

            Assert.AreEqual(1, msgs.Length);
            Assert.True(msgs[0] is DeviceList);
            var msg1 = (DeviceList)msgs[0];

            Assert.AreEqual(6, msg1.Id);
            Assert.AreEqual(2, msg1.Devices.Length);
            Assert.AreEqual("testDev0", msg1.Devices[0].DeviceName);
            Assert.AreEqual(2, msg1.Devices[0].DeviceIndex);
            Assert.AreEqual(2, msg1.Devices[0].DeviceMessages.Count);
            Assert.Contains("StopDeviceCmd", msg1.Devices[0].DeviceMessages.Keys);
            Assert.Null(msg1.Devices[0].DeviceMessages["StopDeviceCmd"].FeatureCount);
            Assert.Contains("VibrateCmd", msg1.Devices[0].DeviceMessages.Keys);
            Assert.AreEqual(1, msg1.Devices[0].DeviceMessages["VibrateCmd"].FeatureCount);
            Assert.AreEqual("testDev1", msg1.Devices[1].DeviceName);
            Assert.AreEqual(5, msg1.Devices[1].DeviceIndex);
            Assert.AreEqual(2, msg1.Devices[1].DeviceMessages.Count);
            Assert.Contains("StopDeviceCmd", msg1.Devices[1].DeviceMessages.Keys);
            Assert.Null(msg1.Devices[1].DeviceMessages["StopDeviceCmd"].FeatureCount);
            Assert.Contains("RotateCmd", msg1.Devices[1].DeviceMessages.Keys);
            Assert.AreEqual(2, msg1.Devices[1].DeviceMessages["RotateCmd"].FeatureCount);

            var str0 = _parser.Serialize(msg, 0);

            Assert.AreEqual(
                "[{\"DeviceList\":{\"Devices\":[{\"DeviceName\":\"testDev0\",\"DeviceIndex\":2,\"DeviceMessages\":[\"StopDeviceCmd\",\"VibrateCmd\"]},{\"DeviceName\":\"testDev1\",\"DeviceIndex\":5,\"DeviceMessages\":[\"StopDeviceCmd\",\"RotateCmd\"]}],\"Id\":6}}]",
                str0);

            msgs = _parser.Deserialize(str0);
            Assert.AreEqual(1, msgs.Length);
            Assert.True(msgs[0] is DeviceListVersion0);
            var msg0 = (DeviceListVersion0)msgs[0];

            Assert.AreEqual(6, msg0.Id);
            Assert.AreEqual(2, msg0.Devices.Length);
            Assert.AreEqual("testDev0", msg0.Devices[0].DeviceName);
            Assert.AreEqual(2, msg0.Devices[0].DeviceIndex);
            Assert.AreEqual(2, msg0.Devices[0].DeviceMessages.Length);
            Assert.Contains("StopDeviceCmd", msg0.Devices[0].DeviceMessages);
            Assert.Contains("VibrateCmd", msg0.Devices[0].DeviceMessages);
            Assert.AreEqual("testDev1", msg0.Devices[1].DeviceName);
            Assert.AreEqual(5, msg0.Devices[1].DeviceIndex);
            Assert.AreEqual(2, msg0.Devices[1].DeviceMessages.Length);
            Assert.Contains("StopDeviceCmd", msg0.Devices[1].DeviceMessages);
            Assert.Contains("RotateCmd", msg0.Devices[1].DeviceMessages);

            msg0 = new DeviceListVersion0(new[]
            {
                new DeviceMessageInfoVersion0(2, "testDev0", new[] { "StopDeviceCmd", "VibrateCmd" }),
                new DeviceMessageInfoVersion0(5, "testDev1", new[] { "StopDeviceCmd", "RotateCmd" }),
            }, 6);
            Assert.AreEqual(6, msg0.Id);
            Assert.AreEqual(2, msg0.Devices.Length);
            Assert.AreEqual("testDev0", msg0.Devices[0].DeviceName);
            Assert.AreEqual(2, msg0.Devices[0].DeviceIndex);
            Assert.AreEqual(2, msg0.Devices[0].DeviceMessages.Length);
            Assert.Contains("StopDeviceCmd", msg0.Devices[0].DeviceMessages);
            Assert.Contains("VibrateCmd", msg0.Devices[0].DeviceMessages);
            Assert.AreEqual("testDev1", msg0.Devices[1].DeviceName);
            Assert.AreEqual(5, msg0.Devices[1].DeviceIndex);
            Assert.AreEqual(2, msg0.Devices[1].DeviceMessages.Length);
            Assert.Contains("StopDeviceCmd", msg0.Devices[1].DeviceMessages);
            Assert.Contains("RotateCmd", msg0.Devices[1].DeviceMessages);
        }
    public static void Main()
    {
        // Print library information:
        PrintInfo.PrintLibraryInfo();

        // Enable network search:
        Network.AutoDetectEnabled = true;

        // Update device list:
        DeviceList.Update();

        // Try to open a generator with triggered burst support:
        Generator gen = null;

        for (UInt32 i = 0; i < DeviceList.Count; i++)
        {
            DeviceListItem item = DeviceList.GetItemByIndex(i);
            if (item.CanOpen(DeviceType.Generator))
            {
                gen = item.OpenGenerator();

                // Check for triggered burst support:
                if ((gen.ModesNative & Constants.GM_BURST_COUNT) != 0 && gen.TriggerInputs.Count > 0)
                {
                    break;
                }
                else
                {
                    gen.Dispose();
                    gen = null;
                }
            }
        }

        if (gen != null)
        {
            try
            {
                // Set signal type:
                gen.SignalType = SignalType.Square;

                // Set frequency:
                gen.Frequency = 100e3; // 100 kHz

                // Set amplitude:
                gen.Amplitude = 2.5; // 2.5 V

                // Set offset:
                gen.Offset = 2.5; // 2.5 V

                // Set symmetry (duty cycle):
                gen.Symmetry = 0.25; // 25 %

                // Set burst mode:
                gen.Mode = GeneratorMode.BurstCount;

                // Set burst count:
                gen.BurstCount = 20; // 20 periods

                // Locate trigger input:
                TriggerInput triggerInput = gen.TriggerInputs.GetById(Constants.TIID_EXT1);

                if (triggerInput == null)
                {
                    triggerInput = gen.TriggerInputs.GetById(Constants.TIID_EXT2);
                }

                if (triggerInput == null)
                {
                    throw new System.Exception("Unknown trigger input!");
                }

                // Enable trigger input:
                triggerInput.Enabled = true;

                // Set trigger input kind:
                triggerInput.Kind = TriggerKind.FallingEdge;

                // Enable output:
                gen.OutputOn = true;

                // Print generator info:
                PrintInfo.PrintDeviceInfo(gen);

                // Start signal generation
                gen.Start();

                // Wait for keystroke:
                Console.WriteLine("Press Enter to stop signal generation...");
                Console.ReadLine();

                // Stop generator:
                gen.Stop();

                // Disable output:
                gen.OutputOn = false;
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
                Environment.Exit(1);
            }

            // Close generator:
            gen.Dispose();
            gen = null;
        }
        else
        {
            Console.WriteLine("No generator available with triggered burst support!");
            Environment.Exit(1);
        }

        Environment.Exit(0);
    }
Esempio n. 15
0
 // 親のデバイスを返す
 // コンポーネントもしくはデバイスを引数にする
 internal Device GetParentDevice(DeployDiagramObject DeployDiagramObject)
 {
     // MessageBox.Show(DeployDiagramObject.ParentID.ToString());
     // DeviceList.ForEach(Device => MessageBox.Show(Device.ID.ToString()));
     return(DeviceList.Single(Device => Device.ID == DeployDiagramObject.ParentID));
 }
Esempio n. 16
0
        internal FOStation(Cumulus cumulus) : base(cumulus)
        {
            cumulus.Manufacturer = cumulus.EW;
            var data = new byte[32];

            tmrDataRead = new Timer();

            calculaterainrate = true;

            hasSolar = cumulus.StationType == StationTypes.FineOffsetSolar;

            if (hasSolar)
            {
                FOentrysize       = 0x14;
                FOMaxAddr         = 0xFFEC;
                maxHistoryEntries = 3264;
            }
            else
            {
                FOentrysize       = 0x10;
                FOMaxAddr         = 0xFFF0;
                maxHistoryEntries = 4080;
            }

            devicelist = DeviceList.Local;

            int VID = (cumulus.VendorID < 0 ? defaultVID : cumulus.VendorID);
            int PID = (cumulus.ProductID < 0 ? defaultPID : cumulus.ProductID);

            cumulus.LogMessage("Looking for Fine Offset station, VendorID=0x" + VID.ToString("X4") + " ProductID=0x" + PID.ToString("X4"));
            cumulus.LogConsoleMessage("Looking for Fine Offset station");

            hidDevice = devicelist.GetHidDeviceOrNull(vendorID: VID, productID: PID);

            if (hidDevice != null)
            {
                cumulus.LogMessage("Fine Offset station found");
                cumulus.LogConsoleMessage("Fine Offset station found");

                if (hidDevice.TryOpen(out stream))
                {
                    cumulus.LogMessage("Stream opened");
                    cumulus.LogConsoleMessage("Connected to station");
                    // Get the block of data containing the abs and rel pressures
                    cumulus.LogMessage("Reading pressure offset");
                    ReadAddress(0x20, data);
                    double relpressure = (((data[1] & 0x3f) * 256) + data[0]) / 10.0f;
                    double abspressure = (((data[3] & 0x3f) * 256) + data[2]) / 10.0f;
                    pressureOffset = relpressure - abspressure;
                    cumulus.LogMessage("Rel pressure      = " + relpressure);
                    cumulus.LogMessage("Abs pressure      = " + abspressure);
                    cumulus.LogMessage("Calculated Offset = " + pressureOffset);
                    if (cumulus.EWpressureoffset < 9999.0)
                    {
                        cumulus.LogMessage("Ignoring calculated offset, using offset value from cumulus.ini file");
                        cumulus.LogMessage("EWpressureoffset = " + cumulus.EWpressureoffset);
                        pressureOffset = cumulus.EWpressureoffset;
                    }

                    // Read the data from the logger
                    startReadingHistoryData();
                }
                else
                {
                    cumulus.LogMessage("Stream open failed");
                    cumulus.LogConsoleMessage("Unable to connect to station");
                }
            }
            else
            {
                cumulus.LogMessage("Fine Offset station not found");
                cumulus.LogConsoleMessage("Fine Offset station not found");
            }
        }
    public static void Main()
    {
        // Print library information:
        PrintInfo.PrintLibraryInfo();

        // Enable network search:
        Network.AutoDetectEnabled = true;

        // Update device list:
        DeviceList.Update();

        // Try to open an oscilloscope with block measurement support and a generator in the same device:
        Oscilloscope scp = null;
        Generator    gen = null;

        for (UInt32 i = 0; i < DeviceList.Count; i++)
        {
            DeviceListItem item = DeviceList.GetItemByIndex(i);
            if (item.CanOpen(DeviceType.Oscilloscope) && item.CanOpen(DeviceType.Generator))
            {
                scp = item.OpenOscilloscope();

                if ((scp.MeasureModes & Constants.MM_BLOCK) != 0)
                {
                    gen = item.OpenGenerator();
                    break;
                }
                else
                {
                    scp.Dispose();
                    scp = null;
                }
            }
        }

        if (scp != null && gen != null)
        {
            try
            {
                // Oscilloscope settings:

                // Get the number of channels:
                UInt16 channelCount = Convert.ToUInt16(scp.Channels.Count);

                // Set measure mode:
                scp.MeasureMode = MeasureMode.Block;

                // Set sample frequency:
                scp.SampleFrequency = 1e6; // 1 MHz

                // Set record length:
                scp.RecordLength = 10000;               // 10 kS
                UInt64 recordLength = scp.RecordLength; // Read actual record length.

                // Set pre sample ratio:
                scp.PreSampleRatio = 0; // 0 %

                // For all channels:
                for (UInt16 ch = 0; ch < channelCount; ch++)
                {
                    OscilloscopeChannel channel = scp.Channels[ch];

                    // Enable channel to measure it:
                    channel.Enabled = true;

                    // Set range:
                    channel.Range = 8; // 8 V

                    // Set coupling:
                    channel.Coupling = Coupling.DCV; // DC Volt
                }

                // Set trigger timeout:
                scp.TriggerTimeOut = 1; // 1 s

                // Disable all channel trigger sources:
                for (UInt16 ch = 0; ch < channelCount; ch++)
                {
                    scp.Channels[ch].Trigger.Enabled = false;
                }

                // Locate trigger input:
                TriggerInput triggerInput = scp.TriggerInputs.GetById(Constants.TIID_GENERATOR_NEW_PERIOD); // or Constants.TIID_GENERATOR_START or Constants.TIID_GENERATOR_STOP

                if (triggerInput == null)
                {
                    throw new System.Exception("Unknown trigger input!");
                }

                // Enable trigger input:
                triggerInput.Enabled = true;

                // Generator settings:

                // Set signal type:
                gen.SignalType = SignalType.Triangle;

                // Set frequency:
                gen.Frequency = 1e3; // 1 kHz

                // Set amplitude:
                gen.Amplitude = 2; // 2 V

                // Set offset:
                gen.Offset = 0; // 0 V

                // Enable output:
                gen.OutputOn = true;

                // Print oscilloscope info:
                PrintInfo.PrintDeviceInfo(scp);

                // Print generator info:
                PrintInfo.PrintDeviceInfo(gen);

                // Start measurement:
                scp.Start();

                // Start signal generation:
                gen.Start();

                // Wait for measurement to complete:
                while (!scp.IsDataReady)
                {
                    Thread.Sleep(10); // 10 ms delay, to save CPU time.
                }

                // Stop generator:
                gen.Stop();

                // Disable output:
                gen.OutputOn = false;

                // Get data:
                float[][] data = scp.GetData();

                // Open file with write/update permissions:
                string       filename = "OscilloscopeGeneratorTrigger.csv";
                StreamWriter file     = new StreamWriter(filename, false);

                // Output CSV data:
                if (File.Exists(filename))
                {
                    // Write csv header:
                    file.Write("Sample");
                    for (UInt16 i = 0; i < channelCount; i++)
                    {
                        file.Write(string.Format(";Ch{0}", i + 1));
                    }
                    file.Write(Environment.NewLine);

                    // Write the data to csv:
                    for (UInt64 i = 0; i < recordLength; i++)
                    {
                        file.Write(i.ToString());
                        for (UInt16 ch = 0; ch < channelCount; ch++)
                        {
                            file.Write(";" + data[ch][i].ToString());
                        }
                        file.Write(Environment.NewLine);
                    }

                    Console.WriteLine("Data written to: " + filename);

                    // Close file:
                    file.Close();
                }
                else
                {
                    Console.WriteLine("Couldn't open file: " + filename);
                    Environment.Exit(1);
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
                Environment.Exit(1);
            }

            // Close oscilloscope:
            scp.Dispose();
            scp = null;

            // Close generator:
            gen.Dispose();
            gen = null;
        }
        else
        {
            Console.WriteLine("No oscilloscope available with block measurement support!");
            Environment.Exit(1);
        }

        Environment.Exit(0);
    }
    public static void Main()
    {
        // Print library information:
        PrintInfo.PrintLibraryInfo();

        // Enable network search:
        Network.AutoDetectEnabled = true;

        // Update device list:
        DeviceList.Update();

        // Try to open an oscilloscope with connection test support:
        Oscilloscope scp = null;

        for (UInt32 i = 0; i < DeviceList.Count; i++)
        {
            DeviceListItem item = DeviceList.GetItemByIndex(i);
            if (item.CanOpen(DeviceType.Oscilloscope))
            {
                scp = item.OpenOscilloscope();

                // Check for connection test support:
                if (scp.HasConnectionTest)
                {
                    break;
                }
                else
                {
                    scp.Dispose();
                    scp = null;
                }
            }
        }

        if (scp != null)
        {
            try
            {
                // Get the number of channels:
                UInt16 channelCount = Convert.ToUInt16(scp.Channels.Count);

                // Enable all channels that support connection testing:
                for (UInt16 Ch = 0; Ch < channelCount; Ch++)
                {
                    scp.Channels[Ch].Enabled = scp.Channels[Ch].HasConnectionTest;
                }

                // Start connection on current active channels:
                scp.StartConnectionTest();

                // Wait for connectiontest to complete:
                while (!scp.IsConnectionTestCompleted)
                {
                    Thread.Sleep(10); // 10 ms delay, to save CPU time.
                }

                // Get data:
                TriState[] Data = scp.GetConnectionTestData();

                // Print results:
                Console.WriteLine("Connection test result:");
                for (UInt16 ch = 0; ch < channelCount; ch++)
                {
                    Console.Write("Ch" + ch.ToString() + " = ");

                    switch (Data[ch])
                    {
                    case TriState.Undefined:
                        Console.WriteLine("undefined");
                        break;

                    case TriState.False:
                        Console.WriteLine("false");
                        break;

                    case TriState.True:
                        Console.WriteLine("true");
                        break;

                    default:
                        Console.WriteLine("unknown state");
                        break;
                    }
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
                Environment.Exit(1);
            }

            // Close oscilloscope:
            scp.Dispose();
            scp = null;
        }
        else
        {
            Console.WriteLine("No oscilloscope available with connection test support!");
            Environment.Exit(1);
        }

        Environment.Exit(0);
    }
Esempio n. 19
0
        private void LoadConfig()
        {
            string configFileContent = LoadConfigFileFromHardDrive();

            devices = BuildObjectFromString(configFileContent);
        }
Esempio n. 20
0
        static void Main()
        {
            var scanner = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (IScanner) new PingAndArp() : (IScanner) new NMapScanner();

            Console.WriteLine($"Inital IP scan of {SubnetAddress} using {scanner.GetType().Name}");
            var sw     = Stopwatch.StartNew();
            var online = scanner.Scan(SubnetAddress).Online;

            foreach (var entry in online)
            {
                Console.WriteLine($"\t{entry.Ip}\t{entry.Mac}");
            }
            Console.WriteLine($"Scan tool {sw.Elapsed}");
            Console.WriteLine();

            var devices = DeviceList.CreateFromFile("devices.json");

            if (devices.Devices.Count(d => d.Type == DeviceType.HueBridge) != 1)
            {
                throw new Exception("Exactly one Hue Bridge must be defined in devices.json");
            }
            devices.ProcessDiscovery(online);

            var hue = (HueBridge)devices.Devices.First(d => d.Type == DeviceType.HueBridge);

            Console.WriteLine("Bridge:");
            Console.WriteLine($"\t{hue.Name,-30}\t{hue.Mac}\t{hue.OnlineStatus.Ip}\t{hue.OnlineStatus.Status}");
            if (hue.OnlineStatus.Status != OnlineStatusOnline.Online)
            {
                throw new Exception("Hue Bridge is not online");
            }
            Console.WriteLine();

            var lights = hue.GetLights();

            Console.WriteLine("Lights:");
            foreach (var light in lights)
            {
                Console.WriteLine($"\t{light.Name,-30}\t{light.TurnedOn}");
            }
            Console.WriteLine();

            var groups = hue.GetGroups();

            Console.WriteLine("Groups:");
            foreach (var grp in groups)
            {
                Console.WriteLine($"\t{grp.Name,-30}\t{grp.TurnedOn}");
            }
            Console.WriteLine();

            var switchable = groups.Concat <ISwitchable>(lights).ToList();

            devices.UpdateDevices(switchable);

            Console.WriteLine("TVs:");
            var tvs = new DeviceList(devices.Devices.Where(d => d.Type == DeviceType.Tv));

            tvs.ProcessDiscovery(online);
            foreach (var tv in tvs.Devices.Cast <Tv>())
            {
                Console.WriteLine($"\t{tv.Name,-30}\t{tv.Mac}\t{tv.OnlineStatus.Status}\t{String.Join(',', tv.ControlNames)}");
            }
            Console.WriteLine();

            var monitor = new DeviceMonitor(SubnetAddress, scanner, tvs);

            monitor.DeviceChanged += (sender, data) =>
            {
                Console.WriteLine($"\t{DateTime.Now:T}\t{data.Device.Name}\t{data.FromStatus}\t->\t{data.ToStatus}");
                if (!(data.Device is Tv tv))
                {
                    return;
                }

                switch (data.ToStatus)
                {
                case OnlineStatusOnline.Online:
                    foreach (var sw in tv.ControlDevices)
                    {
                        sw.TurnOn();
                        Console.WriteLine($"\t{DateTime.Now:T}\t{sw.Name} turned on");
                    }

                    break;

                case OnlineStatusOnline.Offline:
                    foreach (var sw in tv.ControlDevices)
                    {
                        sw.TurnOff();
                        Console.WriteLine($"\t{DateTime.Now:T}\t{sw.Name} turned off");
                    }

                    break;
                }
            };
            monitor.Start();

            var waitEvent = new ManualResetEvent(false);

            Console.CancelKeyPress += (sender, args) =>
            {
                waitEvent.Set();
                args.Cancel = true;
            };

            Console.WriteLine("DeviceMonitor started, Ctrl-C to stop");
            waitEvent.WaitOne();
            monitor.Stop();
            Console.WriteLine("DeviceMonitor stopped");
        }
Esempio n. 21
0
 private string GetConfigAsString(DeviceList devices)
 {
     return(JsonConvert.SerializeObject(devices));
 }
Esempio n. 22
0
        /// <summary>
        /// 串口保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btncom_save_Click(object sender, EventArgs e)
        {
            DeviceList device = new DeviceList();

            device.dname = txtName.Text.ToString();
            switch (cbxType.SelectedIndex)
            {
            case 0:
                device.dtype = "TCP";
                break;

            case 1:
                device.dtype = "串口";
                break;
            }
            //端口号
            switch (cbePortNo.SelectedIndex)
            {
            case 0:
                device.dport = "COM1";
                break;

            case 1:
                device.dport = "COM2";
                break;

            case 2:
                device.dport = "COM3";
                break;

            case 3:
                device.dport = "COM4";
                break;

            case 4:
                device.dport = "COM5";
                break;

            case 5:
                device.dport = "COM6";
                break;

            case 6:
                device.dport = "COM7";
                break;

            case 7:
                device.dport = "COM8";
                break;

            case 8:
                device.dport = "COM9";
                break;
            }

            switch (cbxBoadRate.SelectedIndex)
            {
            case 0:
                device.dbaud = 4800;
                break;

            case 1:
                device.dbaud = 9600;
                break;

            case 2:
                device.dbaud = 14400;
                break;

            case 3:
                device.dbaud = 19200;
                break;

            case 4:
                device.dbaud = 1152;
                break;
            }
            switch (cbxData.SelectedIndex)
            {
            case 0:
                device.ddata = 5;
                break;

            case 1:
                device.ddata = 6;
                break;

            case 2:
                device.ddata = 7;
                break;

            case 3:
                device.ddata = 8;
                break;
            }
            switch (cbxStop.SelectedIndex)
            {
            case 0:
                device.dstop = 1;
                break;

            case 1:
                device.dstop = 2;
                break;
            }

            switch (cbxCheck.SelectedIndex)
            {
            case 0:
                device.dcheck = "None";
                break;

            case 1:
                device.dcheck = "Odd";
                break;

            case 2:
                device.dcheck = "Even";
                break;

            case 3:
                device.dcheck = "Mark";
                break;

            case 4:
                device.dcheck = "Space";
                break;
            }

            int flag = BAL.UpDataByName(device);

            if (flag > 0)
            {
                MessageBox.Show("添加成功");
            }
        }
Esempio n. 23
0
        private void WriteUpdatedConfigFile(DeviceList updatedDevices)
        {
            string devicesAsJsonString = JsonConvert.SerializeObject(updatedDevices);

            File.WriteAllText(configPath, devicesAsJsonString, Encoding.UTF8);
        }
Esempio n. 24
0
        public static joystickaxis getMovingAxis(string name, int threshold)
        {
            self.name = name;
            DeviceList joysticklist = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);

            bool found = false;

            Device joystick = null;

            foreach (DeviceInstance device in joysticklist)
            {
                if (device.ProductName == name)
                {
                    joystick = new Device(device.InstanceGuid);
                    found    = true;
                    break;
                }
            }
            if (!found)
            {
                return(joystickaxis.ARx);
            }

            joystick.SetDataFormat(DeviceDataFormat.Joystick);

            joystick.Acquire();

            // CustomMessageBox.Show("Please ensure you have calibrated your joystick in Windows first");

            // need a pause between aquire and poll
            System.Threading.Thread.Sleep(100);

            joystick.Poll();

            System.Threading.Thread.Sleep(50);

            JoystickState obj    = joystick.CurrentJoystickState;
            Hashtable     values = new Hashtable();

            // get the state of the joystick before.
            Type type = obj.GetType();

            PropertyInfo[] properties = type.GetProperties();
            foreach (PropertyInfo property in properties)
            {
                values[property.Name] = int.Parse(property.GetValue(obj, null).ToString());
            }
            values["Slider1"] = obj.GetSlider()[0];
            values["Slider2"] = obj.GetSlider()[1];
            values["Hatud1"]  = obj.GetPointOfView()[0];
            values["Hatlr2"]  = obj.GetPointOfView()[0];
            values["Custom1"] = 0;
            values["Custom2"] = 0;

            CustomMessageBox.Show("Please move the joystick axis you want assigned to this function after clicking ok");

            DateTime start = DateTime.Now;

            while (start.AddSeconds(10) > DateTime.Now)
            {
                joystick.Poll();
                System.Threading.Thread.Sleep(50);
                JoystickState nextstate = joystick.CurrentJoystickState;

                int[] slider = nextstate.GetSlider();

                int[] hat1 = nextstate.GetPointOfView();

                type       = nextstate.GetType();
                properties = type.GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    //Console.WriteLine("Name: " + property.Name + ", Value: " + property.GetValue(obj, null));

                    log.InfoFormat("test name {0} old {1} new {2} ", property.Name, values[property.Name], int.Parse(property.GetValue(nextstate, null).ToString()));
                    log.InfoFormat("{0}  {1} {2}", property.Name, (int)values[property.Name], (int.Parse(property.GetValue(nextstate, null).ToString()) + threshold));
                    if ((int)values[property.Name] > (int.Parse(property.GetValue(nextstate, null).ToString()) + threshold) ||
                        (int)values[property.Name] < (int.Parse(property.GetValue(nextstate, null).ToString()) - threshold))
                    {
                        log.Info(property.Name);
                        joystick.Unacquire();
                        return((joystickaxis)Enum.Parse(typeof(joystickaxis), property.Name));
                    }
                }

                // slider1
                if ((int)values["Slider1"] > (slider[0] + threshold) ||
                    (int)values["Slider1"] < (slider[0] - threshold))
                {
                    joystick.Unacquire();
                    return(joystickaxis.Slider1);
                }

                // slider2
                if ((int)values["Slider2"] > (slider[1] + threshold) ||
                    (int)values["Slider2"] < (slider[1] - threshold))
                {
                    joystick.Unacquire();
                    return(joystickaxis.Slider2);
                }

                // Hatud1
                if ((int)values["Hatud1"] != (hat1[0]))
                {
                    joystick.Unacquire();
                    return(joystickaxis.Hatud1);
                }

                // Hatlr2
                if ((int)values["Hatlr2"] != (hat1[0]))
                {
                    joystick.Unacquire();
                    return(joystickaxis.Hatlr2);
                }
            }

            CustomMessageBox.Show("No valid option was detected");

            return(joystickaxis.None);
        }
Esempio n. 25
0
        public override bool CheckDevice(string deviceId)
        {
            var device = DeviceList?.FirstOrDefault(m => m.DeviceId == deviceId);

            return((device != null) ? true : false);
        }
Esempio n. 26
0
        /// <summary>
        /// Get a listing of installed devices
        /// </summary>
        /// <returns>List of installed devices</returns>
        public async Task <List <Device> > GetDeviceList()
        {
            DeviceList deviceList = await this.Get <DeviceList>(InstalledDevicesApi);

            return(deviceList.Devices);
        }
Esempio n. 27
0
        public void MergeFrom(ServiceRequest other)
        {
            if (other == null)
            {
                return;
            }
            if (other.Topic.Length != 0)
            {
                Topic = other.Topic;
            }
            switch (other.TypeCase)
            {
            case TypeOneofCase.Client:
                if (Client == null)
                {
                    Client = new global::Ubii.Clients.Client();
                }
                Client.MergeFrom(other.Client);
                break;

            case TypeOneofCase.Device:
                if (Device == null)
                {
                    Device = new global::Ubii.Devices.Device();
                }
                Device.MergeFrom(other.Device);
                break;

            case TypeOneofCase.TopicSubscription:
                if (TopicSubscription == null)
                {
                    TopicSubscription = new global::Ubii.Services.Request.TopicSubscription();
                }
                TopicSubscription.MergeFrom(other.TopicSubscription);
                break;

            case TypeOneofCase.Session:
                if (Session == null)
                {
                    Session = new global::Ubii.Sessions.Session();
                }
                Session.MergeFrom(other.Session);
                break;

            case TypeOneofCase.SessionList:
                if (SessionList == null)
                {
                    SessionList = new global::Ubii.Sessions.SessionList();
                }
                SessionList.MergeFrom(other.SessionList);
                break;

            case TypeOneofCase.Interaction:
                if (Interaction == null)
                {
                    Interaction = new global::Ubii.Interactions.Interaction();
                }
                Interaction.MergeFrom(other.Interaction);
                break;

            case TypeOneofCase.InteractionList:
                if (InteractionList == null)
                {
                    InteractionList = new global::Ubii.Interactions.InteractionList();
                }
                InteractionList.MergeFrom(other.InteractionList);
                break;

            case TypeOneofCase.TopicMux:
                if (TopicMux == null)
                {
                    TopicMux = new global::Ubii.Devices.TopicMux();
                }
                TopicMux.MergeFrom(other.TopicMux);
                break;

            case TypeOneofCase.TopicMuxList:
                if (TopicMuxList == null)
                {
                    TopicMuxList = new global::Ubii.Devices.TopicMuxList();
                }
                TopicMuxList.MergeFrom(other.TopicMuxList);
                break;

            case TypeOneofCase.TopicDemux:
                if (TopicDemux == null)
                {
                    TopicDemux = new global::Ubii.Devices.TopicDemux();
                }
                TopicDemux.MergeFrom(other.TopicDemux);
                break;

            case TypeOneofCase.TopicDemuxList:
                if (TopicDemuxList == null)
                {
                    TopicDemuxList = new global::Ubii.Devices.TopicDemuxList();
                }
                TopicDemuxList.MergeFrom(other.TopicDemuxList);
                break;

            case TypeOneofCase.ClientList:
                if (ClientList == null)
                {
                    ClientList = new global::Ubii.Clients.ClientList();
                }
                ClientList.MergeFrom(other.ClientList);
                break;

            case TypeOneofCase.DeviceList:
                if (DeviceList == null)
                {
                    DeviceList = new global::Ubii.Devices.DeviceList();
                }
                DeviceList.MergeFrom(other.DeviceList);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
 private void InitDeviceList()
 {
   _deviceList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
 }
Esempio n. 29
0
        private void Joystick_Load(object sender, EventArgs e)
        {
            try
            {
                DeviceList joysticklist = Joystick.getDevices();

                foreach (DeviceInstance device in joysticklist)
                {
                    CMB_joysticks.Items.Add(device.ProductName);
                }
            }
            catch { CustomMessageBox.Show("Error geting joystick list: do you have the directx redist installed?"); this.Close(); return; }

            if (CMB_joysticks.Items.Count > 0)
            {
                CMB_joysticks.SelectedIndex = 0;
            }

            CMB_CH1.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH2.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH3.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH4.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH5.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH6.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH7.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH8.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));

            try
            {
                /*
                 * //CMB_CH1
                 * CMB_CH1.Text = MainV2.config["CMB_CH1"].ToString();
                 * CMB_CH2.Text = MainV2.config["CMB_CH2"].ToString();
                 * CMB_CH3.Text = MainV2.config["CMB_CH3"].ToString();
                 * CMB_CH4.Text = MainV2.config["CMB_CH4"].ToString();
                 * CMB_CH5.Text = MainV2.config["CMB_CH5"].ToString();
                 * CMB_CH6.Text = MainV2.config["CMB_CH6"].ToString();
                 * CMB_CH7.Text = MainV2.config["CMB_CH7"].ToString();
                 * CMB_CH8.Text = MainV2.config["CMB_CH8"].ToString();
                 *
                 * //revCH1
                 * revCH1.Checked = bool.Parse(MainV2.config["revCH1"].ToString());
                 * revCH2.Checked = bool.Parse(MainV2.config["revCH2"].ToString());
                 * revCH3.Checked = bool.Parse(MainV2.config["revCH3"].ToString());
                 * revCH4.Checked = bool.Parse(MainV2.config["revCH4"].ToString());
                 * revCH5.Checked = bool.Parse(MainV2.config["revCH5"].ToString());
                 * revCH6.Checked = bool.Parse(MainV2.config["revCH6"].ToString());
                 * revCH7.Checked = bool.Parse(MainV2.config["revCH7"].ToString());
                 * revCH8.Checked = bool.Parse(MainV2.config["revCH8"].ToString());
                 *
                 * //expo_ch1
                 * expo_ch1.Text = MainV2.config["expo_ch1"].ToString();
                 * expo_ch2.Text = MainV2.config["expo_ch2"].ToString();
                 * expo_ch3.Text = MainV2.config["expo_ch3"].ToString();
                 * expo_ch4.Text = MainV2.config["expo_ch4"].ToString();
                 * expo_ch5.Text = MainV2.config["expo_ch5"].ToString();
                 * expo_ch6.Text = MainV2.config["expo_ch6"].ToString();
                 * expo_ch7.Text = MainV2.config["expo_ch7"].ToString();
                 * expo_ch8.Text = MainV2.config["expo_ch8"].ToString();
                 */
                CHK_elevons.Checked = bool.Parse(MainV2.config["joy_elevons"].ToString());
            }
            catch { } // IF 1 DOESNT EXIST NONE WILL

            var tempjoystick = new Joystick();

            label14.Text += " " + MainV2.comPort.MAV.cs.firmware.ToString();

            for (int a = 1; a <= 8; a++)
            {
                var config = tempjoystick.getChannel(a);

                findandsetcontrol("CMB_CH" + a, config.axis.ToString());
                findandsetcontrol("revCH" + a, config.reverse.ToString());
                findandsetcontrol("expo_ch" + a, config.expo.ToString());
            }

            if (MainV2.joystick != null && MainV2.joystick.enabled)
            {
                timer1.Start();
                BUT_enable.Text = "Disable";
            }

            startup = false;
        }
 private void InitDeviceList()
 {
     _deviceList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
 }
    public static void Main()
    {
        // Print library information:
        PrintInfo.PrintLibraryInfo();

        // Enable network search:
        Network.AutoDetectEnabled = true;

        // Update device list:
        DeviceList.Update();

        // Try to open a generator with arbitrary support:
        Generator gen = null;

        for (UInt32 i = 0; i < DeviceList.Count; i++)
        {
            DeviceListItem item = DeviceList.GetItemByIndex(i);
            if (item.CanOpen(DeviceType.Generator))
            {
                gen = item.OpenGenerator();

                // Check for arbitrary support:
                if ((gen.SignalTypes & Constants.ST_ARBITRARY) != 0)
                {
                    break;
                }
                else
                {
                    gen.Dispose();
                    gen = null;
                }
            }
        }

        if (gen != null)
        {
            try
            {
                // Set signal type:
                gen.SignalType = SignalType.Arbitrary;

                // Select frequency mode:
                gen.FrequencyMode = FrequencyMode.SampleFrequency;

                // Set frequency:
                gen.Frequency = 100e3; // 100 kHz

                // Set amplitude:
                gen.Amplitude = 2; // 2 V

                // Set offset:
                gen.Offset = 0; // 0 V

                // Enable output:
                gen.OutputOn = true;

                // Create signal array:
                float[] data = new float[8192];
                for (UInt16 i = 0; i < data.Length; i++)
                {
                    data[i] = (float)(Math.Sin(i / 100.0) * (1 - (i / 8192.0)));
                }

                // Load the signal array into the generator:
                gen.SetData(data);

                // Print generator info:
                PrintInfo.PrintDeviceInfo(gen);

                // Start signal generation:
                gen.Start();

                // Wait for keystroke:
                Console.WriteLine("Press Enter to stop signal generation...");
                Console.ReadLine();

                // Stop generator:
                gen.Stop();

                // Disable output:
                gen.OutputOn = false;
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
                Environment.Exit(1);
            }

            // Close generator:
            gen.Dispose();
            gen = null;
        }
        else
        {
            Console.WriteLine("No generator available with arbitrary support!");
            Environment.Exit(1);
        }

        Environment.Exit(0);
    }
Esempio n. 32
0
        private void Joystick_Load(object sender, EventArgs e)
        {
            try
            {
                DeviceList joysticklist = Joystick.getDevices();

                foreach (DeviceInstance device in joysticklist)
                {
                    CMB_joysticks.Items.Add(device.ProductName);
                }
            }
            catch { CustomMessageBox.Show("Error geting joystick list: do you have the directx redist installed?"); this.Close(); return; }

            if (CMB_joysticks.Items.Count > 0)
            {
                CMB_joysticks.SelectedIndex = 0;
            }

            CMB_CH1.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH2.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH3.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH4.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH5.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH6.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH7.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));
            CMB_CH8.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis)));

            try
            {
                //CMB_CH1
                CMB_CH1.Text = MainV2.config["CMB_CH1"].ToString();
                CMB_CH2.Text = MainV2.config["CMB_CH2"].ToString();
                CMB_CH3.Text = MainV2.config["CMB_CH3"].ToString();
                CMB_CH4.Text = MainV2.config["CMB_CH4"].ToString();
                CMB_CH5.Text = MainV2.config["CMB_CH5"].ToString();
                CMB_CH6.Text = MainV2.config["CMB_CH6"].ToString();
                CMB_CH7.Text = MainV2.config["CMB_CH7"].ToString();
                CMB_CH8.Text = MainV2.config["CMB_CH8"].ToString();

                //revCH1
                revCH1.Checked = bool.Parse(MainV2.config["revCH1"].ToString());
                revCH2.Checked = bool.Parse(MainV2.config["revCH2"].ToString());
                revCH3.Checked = bool.Parse(MainV2.config["revCH3"].ToString());
                revCH4.Checked = bool.Parse(MainV2.config["revCH4"].ToString());
                revCH5.Checked = bool.Parse(MainV2.config["revCH5"].ToString());
                revCH6.Checked = bool.Parse(MainV2.config["revCH6"].ToString());
                revCH7.Checked = bool.Parse(MainV2.config["revCH7"].ToString());
                revCH8.Checked = bool.Parse(MainV2.config["revCH8"].ToString());

                //expo_ch1
                expo_ch1.Text = MainV2.config["expo_ch1"].ToString();
                expo_ch2.Text = MainV2.config["expo_ch2"].ToString();
                expo_ch3.Text = MainV2.config["expo_ch3"].ToString();
                expo_ch4.Text = MainV2.config["expo_ch4"].ToString();
                expo_ch5.Text = MainV2.config["expo_ch5"].ToString();
                expo_ch6.Text = MainV2.config["expo_ch6"].ToString();
                expo_ch7.Text = MainV2.config["expo_ch7"].ToString();
                expo_ch8.Text = MainV2.config["expo_ch8"].ToString();

                CHK_elevons.Checked = bool.Parse(MainV2.config["joy_elevons"].ToString());
            }
            catch { } // IF 1 DOESNT EXIST NONE WILL

            if (MainV2.joystick != null && MainV2.joystick.enabled)
            {
                timer1.Start();
                BUT_enable.Text = "Disable";
            }

            startup = false;
        }
        public bool InitDevice()
        {
            SettingView     = false;
            AuthProcessView = false;

            ThermostatAPI api = Global.Instance.ThermostatAPI;

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            string token = localSettings.Values["NestAccessToken"] as string;

            if (string.IsNullOrEmpty(token))
            {
                Setting();

                return(false);
            }
            else
            {
                api.ApplyAccessToken(token);

                Task <bool> t = Task.Run(async() => await api.GetDevices());
                t.Wait();

                if (t.Result)
                {
                    int count = DeviceList.Count;
                    if (0 == count)
                    {
                        foreach (ThermostatDevice d in api.ThermostatDevices)
                        {
                            FanDuration nfd = DurationList.Where(L => L.Duration == d.fan_timer_duration.ToString()).SingleOrDefault();

                            Models.Thermostat nts = new Models.Thermostat(d);
                            nts.Duration     = nfd;
                            nts.RollDuration = nfd;

                            nts.Tick = 1; //("C" == nts.temperature_scale) ? 1 : 2;

                            nts.FanRun  = nts.fan_timer_active == true;
                            nts.FanStop = nts.fan_timer_active == false;

                            if (d == api.ThermostatDevices.First())
                            {
                                nts.FanBrush     = new SolidColorBrush(Colors.White);
                                nts.FanBallBrush = new SolidColorBrush(Colors.White);

                                nts.Duration.Brush     = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xcb, 0x00));
                                nts.Duration.BallBrush = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xcb, 0x00));
                            }

                            DeviceList.Add(nts);
                        }
                    }
                    else
                    {
                        if (api.ThermostatDevices.Count < count)
                        {
                            DeviceList.Clear();
                        }

                        foreach (ThermostatDevice d in api.ThermostatDevices)
                        {
                            FanDuration nfd = DurationList.Where(L => L.Duration == d.fan_timer_duration.ToString()).SingleOrDefault();

                            Models.Thermostat tm = DeviceList.Where(T => T.device_id == d.device_id).SingleOrDefault();
                            if (null == tm || string.IsNullOrEmpty(tm.device_id))
                            {
                                Models.Thermostat nts = new Models.Thermostat(d);
                                nts.Duration     = nfd;
                                nts.RollDuration = nfd;

                                nts.Tick = 1; //("C" == nts.temperature_scale) ? 1 : 2;

                                nts.FanRun  = nts.fan_timer_active == true;
                                nts.FanStop = nts.fan_timer_active == false;

                                DeviceList.Add(nts);
                                continue;
                            }

                            if (null != tm || false == string.IsNullOrEmpty(tm.device_id))
                            {
                                tm.Update(d, nfd);
                            }
                        }
                    }

                    if (firstInit)
                    {
                        firstInit            = false;
                        OnTemperatureSetting = true;
                    }

                    return(true);
                }
                else
                {
                    Setting();
                }

                return(false);
            }
        }
Esempio n. 34
0
 private void Main_Click(object sender, EventArgs e)
 {
     DeviceList.ClearSelected();
 }
Esempio n. 35
0
 public void InitDeviceList()
 {
   try
   {
     _deviceList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly);
     _deviceNames.Clear();
     _deviceGUIDs.Clear();
     if (null == _deviceList)
     {
       return;
     }
     _deviceList.Reset();
     foreach (DeviceInstance di in _deviceList)
     {
       if (Manager.GetDeviceAttached(di.InstanceGuid))
       {
         _deviceNames.Add(di.InstanceName);
         _deviceGUIDs.Add(di.InstanceGuid);
       }
     }
   }
   catch (Exception ex)
   {
     Log.Info("DirectInputHandler: error in InitDeviceList");
     Log.Info(ex.Message.ToString());
   }
 }
Esempio n. 36
0
        private void Configure()
        {
            this.licensesMenuItem   = this.FindControl <MenuItem>("licensesMenuItem");
            licensesMenuItem.Click += (async(s, e) =>
            {
                var window = new LicenseWindow();
                await window.ShowDialog(this);
            });
            this.scanMenuItem   = this.FindControl <MenuItem>("scanMenuItem");
            scanMenuItem.Click += (s, e) => { LookForDevices(); };

            ConnectedDevices            = new ObservableCollection <RoxyDevice>();
            this.boardGrid              = this.FindControl <DataGrid>("boardGrid");
            boardGrid.DataContext       = this;
            boardGrid.SelectionChanged += BoardGrid_SelectionChanged;

            this.tabControl = this.FindControl <TabControl>("tabControl");

            this.loadElfButton    = this.FindControl <Button>("loadElfButton");
            loadElfButton.Click  += LoadElfFile;
            this.elfFilenameText  = this.FindControl <TextBlock>("elfFilenameText");
            this.flashElfButton   = this.FindControl <Button>("flashElfButton");
            flashElfButton.Click += FlashElfButton;

            this.consoleText      = this.FindControl <TextBlock>("consoleText");
            this.consoleContainer = this.FindControl <Border>("consoleContainer");

            this.configTab = this.FindControl <Grid>("configTab");

            this.configButtons       = this.FindControl <Grid>("configButtons");
            this.readConfigButton    = this.FindControl <Button>("readConfigButton");
            readConfigButton.Click  += ReadConfigButton_Click;
            this.writeConfigButton   = this.FindControl <Button>("writeConfigButton");
            writeConfigButton.Click += WriteConfigButton_Click;

            this.configPanel             = this.FindControl <ConfigPanel>("configPanel");
            configPanel.SubPanelChanged += SubPanelChanged;

            this.rgbControl      = this.FindControl <HueColorSliderControl>("rgbControl");
            rgbControl.OnClosed += rgbControl_Closed;
            this.rgbScrollViewer = this.FindControl <ScrollViewer>("rgbScrollViewer");

            this.keyMappingControl      = this.FindControl <KeyMappingControl>("keyMappingControl");
            keyMappingControl.OnClosed += configControl_Closed;
            this.keyMappingScrollViewer = this.FindControl <ScrollViewer>("keyMappingScrollViewer");

            this.buttonLedControl      = this.FindControl <ButtonLedControl>("buttonLedControl");
            buttonLedControl.OnClosed += configControl_Closed;
            this.buttonLedScrollViewer = this.FindControl <ScrollViewer>("buttonLedScrollViewer");

            this.deviceControl      = this.FindControl <DeviceControl>("deviceControl");
            deviceControl.OnClosed += configControl_Closed;
            this.deviceScrollViewer = this.FindControl <ScrollViewer>("deviceScrollViewer");

            this.joystickMappingControl      = this.FindControl <JoystickMappingControl>("joystickMappingControl");
            joystickMappingControl.OnClosed += configControl_Closed;
            this.joystickMappingScrollViewer = this.FindControl <ScrollViewer>("joystickMappingScrollViewer");

            this.ttControl      = this.FindControl <TurntableControl>("ttControl");
            ttControl.OnClosed += configControl_Closed;
            this.ttScrollViewer = this.Find <ScrollViewer>("ttScrollViewer");

            var svre9left = this.FindControl <Button>("svre9Left");

            svre9left.Click += ((s, e) =>
            {
                SendCommand(1, 0);
            });
            var svre9right = this.FindControl <Button>("svre9Right");

            svre9right.Click += ((s, e) =>
            {
                SendCommand(1, 1);
            });

            flashElfEvent += flashElf;

            RoxyDevice.StatusWrite = delegate(string status)
            {
                StatusWrite(status);
            };

            devList          = DeviceList.Local;
            devList.Changed += DevList_Changed;
            LookForDevices();
        }
Esempio n. 37
0
        void DeviceManager_DeviceList_Initialize()
        {
            if (deviceListPage == null)
            {
                deviceListPage = new DeviceList();

                deviceListPage.AddDeviceSelected += DeviceManager_DeviceList_AddDeviceSelected;
                deviceListPage.EditSelected += DeviceManager_DeviceList_DeviceEditSelected;
            }
        }
Esempio n. 38
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (typeCase_ == TypeOneofCase.Success)
            {
                hash ^= Success.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Error)
            {
                hash ^= Error.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Client)
            {
                hash ^= Client.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Device)
            {
                hash ^= Device.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Server)
            {
                hash ^= Server.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Session)
            {
                hash ^= Session.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.SessionList)
            {
                hash ^= SessionList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Interaction)
            {
                hash ^= Interaction.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.InteractionList)
            {
                hash ^= InteractionList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.StringList)
            {
                hash ^= StringList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicMux)
            {
                hash ^= TopicMux.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicMuxList)
            {
                hash ^= TopicMuxList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicDemux)
            {
                hash ^= TopicDemux.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.TopicDemuxList)
            {
                hash ^= TopicDemuxList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.ClientList)
            {
                hash ^= ClientList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.DeviceList)
            {
                hash ^= DeviceList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Service)
            {
                hash ^= Service.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.ServiceList)
            {
                hash ^= ServiceList.GetHashCode();
            }
            hash ^= (int)typeCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }