Esempio n. 1
0
        static void Main(string[] args)
        {
            //$logger = New-Logger -FileName "c:\temp\netomity-log.txt"
            var logger = new Logger(@"C:\temp\netomity-log.txt");

            var ns = NetomitySystem.Factory();

//$insteonPort = New-SerialIO -Name "InsteonSerial" -PortName "COM5" -PortSpeed 19200
            var insteonPort = new SerialIO(portName: "COM5", portSpeed: 19200);
//$w800Port = New-SerialIO -Name "W800Serial" -PortName "COM4" -PortSpeed 4800
            var w800Port = new SerialIO(portName: "COM4", portSpeed: 4800);
//$insteonTCP = New-TCPServer -Name "InsteonTCP" -PortNumber 3333
            var insteonTCP = new TCPServer(3333);
//$w800TCP = New-TCPServer -Name "W800TCP" -PortNumber 3334
            var W800TCP = new TCPServer(3334);
//$insteonBC = New-BasicConnector -Name "InsteonBC" -Interfaces $insteonPort, $insteonTCP
            var insteonBC = new BasicConnector(insteonPort, insteonTCP);
//$w800BC = New-BasicConnector -Name "W800BC" -Interfaces $w800Port, $w800TCP
            var w800BC = new BasicConnector(w800Port, W800TCP);
//$insteonTask = $insteonBC.Open()
            var insteonTask = insteonBC.Open();

            //$w800Task = $w800BC.Open()
            var w800Task = w800BC.Open();

//$insteonTask.Wait();
//            insteonTask.Wait();
//            Thread.Sleep(60000);
            ns.Run();
        }
Esempio n. 2
0
        public IHttpActionResult NetomityObjects(string type)
        {
            NetomityObjectType not = Conversions.ValueToStringEnum <NetomityObjectType>(type);

            var objs = NetomitySystem.Factory().NetomityObjects.Where(o => o.Type == not).ToList();

//            return _JSONResponse<List<NetomityObject>>(true, objs);
            return(Json(objs));
        }
Esempio n. 3
0
        public HttpResponseMessage Get()
        {
            foreach (var kp in Request.GetOwinContext().Environment)
            {
                var a = 0;
            }
            var objs = NetomitySystem.Factory().NetomityObjects;

            return(RenderPage <IQueryable <NetomityObject> >(BaseFolder + "index.html", objs));
        }
Esempio n. 4
0
        public IHttpActionResult SetNetomityObjectProperty(string id, string property, string primary, string secondary = null)
        {
            Int32 iid = 0;
            IQueryable <NetomityObject> nsojbs = null;
            List <NetomityObject>       objs   = null;
            NetomityObject obj    = null;
            bool           status = false;

            nsojbs = NetomitySystem.Factory().NetomityObjects;
            //            var objs = c_objects.Where(o =>).ToList();
            if (Int32.TryParse(id, out iid))
            {
                objs = nsojbs.Where(o => o.Id == iid).ToList();
            }

            if (iid == 0 || objs.Count() == 0)
            {
                objs = nsojbs.Where(o => o.Name != null && o.Name.ToLower() == id.ToLower()).ToList();
            }


            if (objs.Count() > 0)
            {
                obj = objs.First();
                var sd = (StateDevice)obj;
                switch (property.ToLower())
                {
                case "command":
                    sd.Command(Conversions.ValueToStringEnum <CommandType>(primary), secondary);
                    status = true;
                    break;

                case "state":
                    var state = new State()
                    {
                        Primary   = Conversions.ValueToStringEnum <StateType>(primary),
                        Secondary = secondary
                    };
                    sd.State = state;
                    status   = true;
                    break;
                }
            }

            //return _JSONResponse<NetomityObject>(status, obj);
            return(Json(obj));
        }
Esempio n. 5
0
        public HttpResponseMessage Devices(FormDataCollection formData)
        {
            var allDevices = NetomitySystem.Factory().NetomityObjects.Where(o => o.Type == NetomityObjectType.Device).Cast <StateDevice>();

            if (formData != null && formData.Count() > 0)
            {
                var fDevice = formData.FirstOrDefault();
                var device  = allDevices.Where(d => d.Id.ToString() == formData.First().Key).FirstOrDefault();
                if (device != null)
                {
                    device.Command(fDevice.Value);
                }
            }


//            return _JSONResponse<List<NetomityObject>>(true, objs);
            return(RenderPage <IEnumerable <StateDevice> >(BaseFolder + "devicecontrol.html", allDevices));
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            //const string BASE_ADDR = "http://*****:*****@"C:\projects\Netomity\Netomity\Web\Content\";


            var logger = new Logger(@"C:\temp\netomity-log.txt");

            var ns = NetomitySystem.Factory();

            var tp  = new TCPClient(address: "192.168.12.161", port: 3333);
            var plm = new Insteon(iface: tp);

            var test_lamp = new StateDevice(address: "00.5B.5d", iface: plm)
            {
                Name = "TestLamp1"
            };

            var master_fan = new StateDevice(address: "1f.ad.76", iface: plm)
            {
                Name = "Master Fan"
            };

            var master_light = new StateDevice(address: "38.2e.a2", iface: plm)
            {
                Name = "Master Light"
            };

            var Bedtime = new Scene(devices: new List <StateDevice>()
            {
                test_lamp
            })
            {
                Name = "Bedtime"
            };

            //var rh = new RestHost(address: BASE_ADDR);
            var wh = new WebHost(address: BASE_ADDR, filePath: BASE_FOLDER);

            ns.Run();
        }
Esempio n. 7
0
 protected override void ProcessRecord()
 {
     WriteVerbose(String.Format("New NetomitySystem"));
     WriteObject(NetomitySystem.Factory());
 }