コード例 #1
0
        public string MakeNewRule()
        {
            var dv = Instance.host.NewDeviceRef("R");


            Scheduler.Classes.DeviceClass newDevice = (Scheduler.Classes.DeviceClass)Instance.host.GetDeviceByRef(dv);
            newDevice.set_InterfaceInstance(Instance.host, Instance.name);
            newDevice.set_Name(Instance.host, "Type Meter Calc " + dv);
            //newDevice.set_Location2(Instance.host, "ScratchpadRule");
            newDevice.set_Location(Instance.host, "Utilities");
            newDevice.set_Location2(Instance.host, "Calcs");
            //newDevice.set_Interface(Instance.host, "Modbus Configuration");//Put here the registered name of the page for what we want in the Modbus tab!!!  So easy!
            newDevice.set_Interface(Instance.host, Util.IFACE_NAME); //Needed to link device to plugin, so the tab calls back to the correct hardcoded homeseer function
                                                                     //newDevice.set_InterfaceInstance()''  SET INTERFACE INSTANCE
            newDevice.set_Relationship(Instance.host, Enums.eRelationship.Not_Set);

            newDevice.MISC_Set(Instance.host, Enums.dvMISC.NO_LOG);
            newDevice.MISC_Set(Instance.host, Enums.dvMISC.SHOW_VALUES);
            // newDevice.MISC_Set(Instance.host, Enums.dvMISC.HIDDEN);
            HomeSeerAPI.PlugExtraData.clsPlugExtraData EDO = new PlugExtraData.clsPlugExtraData();

            // EDO = newDevice.get_PlugExtraData_Get(Instance.host);

            string ruleString = makeNewRules();


            string userNote = newDevice.get_UserNote(Instance.host);

            userNote  = userNote.Split("PLUGIN EXTRA DATA:".ToCharArray())[0];
            userNote += "PLUGIN EXTRA DATA:" + ruleString.ToString();
            newDevice.set_UserNote(Instance.host, userNote);

            EDO.AddNamed("SSIDKey", ruleString);
            newDevice.set_PlugExtraData_Set(Instance.host, EDO);

            // newDevice.set_Device_Type_String(Instance.host, makeNewModbusGateway());
            var DevINFO = new DeviceTypeInfo_m.DeviceTypeInfo();

            DevINFO.Device_API = DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Plug_In;


            newDevice.set_DeviceType_Set(Instance.host, DevINFO);
            Instance.Devices.Add(new SiidDevice(Instance, newDevice));

            MakeStewardVSP(dv);

            return("refresh");
        }
コード例 #2
0
        /// <summary>
        /// Create a new device and set the names for the status display.
        /// </summary>
        /// <param name="refId">The device reference identifier for HomeSeer.</param>
        /// <param name="name">The name for the device.</param>
        /// <returns>Scheduler.Classes.DeviceClass.</returns>
        private Scheduler.Classes.DeviceClass CreateDevice(out int refId, string name = "HikVision Camera")
        {
            Scheduler.Classes.DeviceClass dv = null;
            refId = hs.NewDeviceRef(name);
            if (refId > 0)
            {
                dv = (Scheduler.Classes.DeviceClass)hs.GetDeviceByRef(refId);
                dv.set_Address(hs, "Camera" + refId);
                dv.set_Device_Type_String(hs, "HikVision Camera Alarm");
                DeviceTypeInfo_m.DeviceTypeInfo DT = new DeviceTypeInfo_m.DeviceTypeInfo();
                DT.Device_API  = DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Security;
                DT.Device_Type = (int)DeviceTypeInfo_m.DeviceTypeInfo.eDeviceType_Security.Zone_Interior;
                dv.set_DeviceType_Set(hs, DT);
                dv.set_Interface(hs, IFACE_NAME);
                dv.set_InterfaceInstance(hs, "");
                dv.set_Last_Change(hs, DateTime.Now);
                dv.set_Location(hs, "Camera");     // room
                dv.set_Location2(hs, "HikVision"); // floor

                VSVGPairs.VSPair Pair = new VSVGPairs.VSPair(HomeSeerAPI.ePairStatusControl.Status);
                Pair.PairType = VSVGPairs.VSVGPairType.SingleValue;
                Pair.Value    = -1;
                Pair.Status   = "Unknown";
                Default_VS_Pairs_AddUpdateUtil(refId, Pair);

                Pair          = new VSVGPairs.VSPair(HomeSeerAPI.ePairStatusControl.Status);
                Pair.PairType = VSVGPairs.VSVGPairType.SingleValue;
                Pair.Value    = 0;
                Pair.Status   = "No Motion";
                Default_VS_Pairs_AddUpdateUtil(refId, Pair);

                Pair          = new VSVGPairs.VSPair(HomeSeerAPI.ePairStatusControl.Status);
                Pair.PairType = VSVGPairs.VSVGPairType.SingleValue;
                Pair.Value    = 1;
                Pair.Status   = "Motion";
                Default_VS_Pairs_AddUpdateUtil(refId, Pair);

                dv.MISC_Set(hs, Enums.dvMISC.STATUS_ONLY);
                dv.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES);
                dv.set_Status_Support(hs, true);
            }

            return(dv);
        }
コード例 #3
0
        protected void GetHSDevice()
        {
            hsDevice = Controller.getHSDevice(EnOceanController.EnOceanDeviceType.SimpleDevice, DeviceId);
            if (hsDevice == null)
            {
                if (deviceConfig["node_name"] == null)
                {
                    deviceConfig["node_name"] = DeviceId;
                }
                hsDevice = Controller.createHSDevice((string)deviceConfig["node_name"], EnOceanController.EnOceanDeviceType.SimpleDevice, DeviceId);
                hsDevice.set_Device_Type_String(HS, "EnOcean " + EnOceanController.EnOceanDeviceType.SimpleDevice.ToString());
                hsDevice.set_Relationship(HS, Enums.eRelationship.Parent_Root);
//                hsDevice.MISC_Set(HS, Enums.dvMISC.NO_LOG);
                hsDevice.MISC_Set(HS, Enums.dvMISC.SHOW_VALUES);
                AddOrUpdateHSDeviceProperties();
                SaveConfiguration();
            }
        }
コード例 #4
0
 protected void GetHSDevice()
 {
     hsDevice = Controller.getHSDevice(EnOceanController.EnOceanDeviceType.SimpleDevice, DeviceId);
     if (hsDevice == null)
     {
         if (deviceConfig["node_name"] == null)
             deviceConfig["node_name"] = DeviceId;
         hsDevice = Controller.createHSDevice((string)deviceConfig["node_name"], EnOceanController.EnOceanDeviceType.SimpleDevice, DeviceId);
         hsDevice.set_Device_Type_String(HS, "EnOcean " + EnOceanController.EnOceanDeviceType.SimpleDevice.ToString());
         hsDevice.set_Relationship(HS, Enums.eRelationship.Parent_Root);
     //                hsDevice.MISC_Set(HS, Enums.dvMISC.NO_LOG);
         hsDevice.MISC_Set(HS, Enums.dvMISC.SHOW_VALUES);
         AddOrUpdateHSDeviceProperties();
         SaveConfiguration();
     }
 }
コード例 #5
0
        public string addSubrule(string data)
        {
            //Make a new rule, but make it in service to an existing rule:
            var dv = Instance.host.NewDeviceRef("R");


            Scheduler.Classes.DeviceClass newDevice = (Scheduler.Classes.DeviceClass)Instance.host.GetDeviceByRef(dv);
            newDevice.set_InterfaceInstance(Instance.host, Instance.name);
            newDevice.set_Name(Instance.host, "Type Meter Rate" + dv);
            //   newDevice.set_Location2(Instance.host, "ScratchpadSubRule");
            newDevice.set_Location(Instance.host, "Utilities");
            newDevice.set_Location2(Instance.host, "Rates");

            //newDevice.set_Interface(Instance.host, "Modbus Configuration");//Put here the registered name of the page for what we want in the Modbus tab!!!  So easy!
            newDevice.set_Interface(Instance.host, Util.IFACE_NAME); //Needed to link device to plugin, so the tab calls back to the correct hardcoded homeseer function
                                                                     //newDevice.set_InterfaceInstance()''  SET INTERFACE INSTANCE
            newDevice.set_Relationship(Instance.host, Enums.eRelationship.Not_Set);

            newDevice.MISC_Set(Instance.host, Enums.dvMISC.NO_LOG);
            newDevice.MISC_Set(Instance.host, Enums.dvMISC.SHOW_VALUES);
            // newDevice.MISC_Set(Instance.host, Enums.dvMISC.HIDDEN);
            HomeSeerAPI.PlugExtraData.clsPlugExtraData EDO = new PlugExtraData.clsPlugExtraData();

            // EDO = newDevice.get_PlugExtraData_Get(Instance.host);


            string ruleString = makeNewRules();


            string userNote = newDevice.get_UserNote(Instance.host);

            userNote  = userNote.Split("PLUGIN EXTRA DATA:".ToCharArray())[0];
            userNote += "PLUGIN EXTRA DATA:" + ruleString.ToString();
            newDevice.set_UserNote(Instance.host, userNote);

            EDO.AddNamed("SSIDKey", ruleString);
            newDevice.set_PlugExtraData_Set(Instance.host, EDO);

            // newDevice.set_Device_Type_String(Instance.host, makeNewModbusGateway());
            var DevINFO = new DeviceTypeInfo_m.DeviceTypeInfo();

            DevINFO.Device_API = DeviceTypeInfo_m.DeviceTypeInfo.eDeviceAPI.Plug_In;


            newDevice.set_DeviceType_Set(Instance.host, DevINFO);
            Instance.Devices.Add(new SiidDevice(Instance, newDevice));

            MakeStewardVSP(dv);



            StringBuilder stb       = new StringBuilder();
            var           page      = this;
            string        GatewayID = data.Split("_".ToCharArray())[1];


            SiidDevice GateWay = SiidDevice.GetFromListByID(Instance.Devices, Convert.ToInt32(GatewayID));

            Scheduler.Classes.DeviceClass Gateway = GateWay.Device; //Should keep in gateway a list of devices

            Gateway.AssociatedDevice_Add(Instance.host, dv);        //This is totally working actually

            return("refresh");

            stb.Append("<meta http-equiv=\"refresh\" content = \"0; URL='/deviceutility?ref=" + dv + "&edit=1'\" />");
            //    stb.Append("<a id = 'LALA' href='/deviceutility?ref=" + dv + "&edit=1'/><script>LALA.click()</script> ");
            page.AddBody(stb.ToString());
            return(page.BuildPage());
        }