Ejemplo n.º 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();
    }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
//			DeviceSearch.SearchForDevices ();
//
//			while (true) {
//				Thread.Sleep (1000);
//				Console.WriteLine ("Still running!");
//			}
//
//			Console.WriteLine (HeepLanguage.AddMOPOpCode);
//
            Console.WriteLine("Hello World!");

            TestGetNumberFromBuffer();

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

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

            DeviceID    myID     = new DeviceID(ID);
            HeepDevice  myDevice = new HeepDevice(myID);
            List <byte> myMem    = new List <Byte> ();

            Console.WriteLine(myMem.Count);
            HeepLanguage.AddNameToMemory(myMem, myID, "Twilio");
            Console.WriteLine(myMem.Count);
            for (int i = 0; i < myMem.Count; i++)
            {
                Console.Write(myMem [i] + " ");
            }
            Console.WriteLine();


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

            myDevice.AddControl(theControl);

            Control outputControl = Control.CreateControl(Control.CtrlInputOutput.output, Control.CtrlType.OnOff, "UnityOut");

            myDevice.AddControl(outputControl);

            List <byte> newOutput = myDevice.GetMemoryDump();

            for (int i = 0; i < newOutput.Count; i++)
            {
                Console.Write(newOutput [i] + " ");
            }
            Console.WriteLine();

            byte []   IPAddrArray = { 192, 168, 1, 100 };
            IPAddress theAddr     = new IPAddress(IPAddrArray);

            byte [] theArr = theAddr.GetAddressBytes();
            Console.WriteLine(theAddr.ToString());
            for (int i = 0; i < theArr.Length; i++)
            {
                Console.Write(theArr [i] + ".");
            }
            Console.WriteLine();

            myDevice.SetDeviceName("UNITY");

            //NonVolatileData.WriteMemoryToFile (myDevice.GetMemoryDump ());
            List <Byte> curMemory = NonVolatileData.ReadMemoryFromFile();

            List <Byte> MemDump = myDevice.GetMemoryDump();

            for (int i = 0; i < MemDump.Count; i++)
            {
                Console.Write(MemDump [i]);
                Console.Write(" ");
            }
            Console.WriteLine();

            for (int i = 0; i < curMemory.Count; i++)
            {
                Console.Write(curMemory [i]);
                Console.Write(" ");
            }
            Console.WriteLine();

            int counter = 1;

            Console.WriteLine(HeepParser.parseDeviceNameMOP(curMemory, ref counter));

//			HeepCommunications.StartHeepServer (myDevice);
//
//			byte value = 0;
//			while (true) {
//				Console.Write ("Enter something to send stuff: ");
//				String newRead = Console.ReadLine ();
//				Console.WriteLine (newRead);
//
//				myDevice.SetControlByID (1, value);
//
//				if (value == 0)
//					value = 1;
//				else
//					value = 0;
//
////				byte [] IPAddrArraya = {192, 168, 0, 103};
////				IPAddress theAddra = new IPAddress(IPAddrArraya);
////				List<byte> newBuf = new List<byte>();
////				newBuf.Add (0x0A);
////				newBuf.Add (0x02);
////				newBuf.Add (0x00);
////				newBuf.Add (value);
////				HeepCommunications.SendBufferToIP (newBuf, theAddra);
////
////				if (value == 0) {
////					value = 1;
////				}
////				else{
////					value = 0;
////				}
//
//			}
        }