Пример #1
0
    void CreateHeepDevice()
    {
        List <byte> ID = new List <byte>();

        for (byte i = 0; i < 4; i++)
        {
            ID.Add(i);
        }

        DeviceID myID = new DeviceID(ID);

        myDevice = new HeepDevice(myID);

        myDevice.LoadDeviceMemoryFromFile();

        Control theControl = Control.CreateControl(Control.CtrlInputOutput.input, Control.CtrlType.OnOff, "First", sendAnalytics);

        myDevice.AddControl(theControl);
        Control newControl = Control.CreateControl(Control.CtrlInputOutput.output, Control.CtrlType.OnOff, "Second", sendAnalytics);

        myDevice.AddControl(newControl);
        Control bufferControl = new BufferControl(0, Control.CtrlInputOutput.output, Control.CtrlType.buffer, 10, 0, 0, "Buffer", true);

        myDevice.AddControl(bufferControl);
        myDevice.SetDeviceNameStartup("Unity");
        myDevice.StartListening();
    }
Пример #2
0
        public MainForm()
        {
            //CreateTemplateXML();

            long          readInDeviceID = 0;
            string        deviceName     = "";
            XmlTextReader textReader     = new XmlTextReader("TrackerSettings.xml");

            while (textReader.Read())
            {
                switch (textReader.NodeType)
                {
                case XmlNodeType.Element:     // The node is an element.
                    if (textReader.Name == "Name")
                    {
                        textReader.Read();
                        deviceName = textReader.Value;
                    }
                    else if (textReader.Name == "SamplePeriod")
                    {
                        textReader.Read();
                        allowableDownTime = Double.Parse(textReader.Value);
                    }
                    else if (textReader.Name == "DeviceID")
                    {
                        textReader.Read();
                        readInDeviceID = long.Parse(textReader.Value);
                    }

                    Console.Write("<" + textReader.Name);
                    Console.WriteLine(">");
                    break;
                }
            }

            List <byte> ID = new List <byte>();

            for (byte i = 0; i < 4; i++)
            {
                ID.Add((byte)(readInDeviceID >> 3 * 8 - i * 8 & 0xFF));
            }

            DeviceID myID = new DeviceID(ID);

            myDevice = new HeepDevice(myID);

            myDevice.AddControl(Heep.Control.CreateControl(Heep.Control.CtrlInputOutput.input, Heep.Control.CtrlType.OnOff, "Key Up", true));

            myDevice.SetDeviceNameStartup(deviceName);
            myDevice.StartListening();

            InitializeComponent();

            System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 5000;
            aTimer.Enabled  = true;
        }