Example #1
0
        public static void Main(string[] args)
        {
            string serverAddress = DEFAULT_SERVER_ADDRESS;
            int    serverPort    = DEFAULT_SERVER_PORT;

            LifxClient.Debug.LineLogged += (object sender, LifxClient.DebugLineEventArgs eventArgs) => {
                if (!eventArgs.LogLine.Contains("Type = StateService"))
                {
                    WriteLog("verbose", "[LIFX] " + eventArgs.LogLine, eventArgs.LineNumber, eventArgs.CallerName);
                }
            };

            foreach (string arg in args)
            {
                string[] parts = arg.Split('=');
                switch (parts[0].ToLower())
                {
                case "server":
                    serverAddress = parts[1];
                    break;

                default:
                    Console.WriteLine("Warning: Unknown command line argument " + parts[0]);
                    break;
                }
            }

            HSPI plugin = new HSPI();

            Console.WriteLine("Plugin " + plugin.Name + " is connecting to HS3 at " + serverAddress + ":" + serverPort);
            try {
                plugin.Connect(serverAddress, serverPort);
                Console.WriteLine("Connection established");
            }
            catch (Exception ex) {
                Console.WriteLine("Unable to connect to HS3: " + ex.Message);
                return;
            }

            try {
                while (true)
                {
                    System.Threading.Thread.Sleep(250);
                    if (!plugin.Connected)
                    {
                        Console.WriteLine("Connection to HS3 lost!");
                        break;
                    }

                    if (plugin.Shutdown)
                    {
                        Console.WriteLine("Plugin has been shut down; exiting");
                        break;
                    }
                }
            }
            catch (Exception ex) {
                Console.WriteLine("Unhandled exception: " + ex.Message);
            }
        }
Example #2
0
 public EnOceanController(IHSApplication pHsHost, IAppCallbackAPI pHsCB, HSPI pHspiInst, JObject initCfg)
 {
     hspiInst           = pHspiInst;
     HS                 = pHsHost;
     HSCB               = pHsCB;
     config             = initCfg;
     portName           = (string)config["portname"];
     UniqueControllerId = (string)config["unique_id"];
 }
 public EnOceanController(IHSApplication pHsHost, IAppCallbackAPI pHsCB, HSPI pHspiInst, JObject initCfg)
 {
     hspiInst = pHspiInst;
     HS = pHsHost;
     HSCB = pHsCB;
     config = initCfg;
     portName = (string)config["portname"];
     UniqueControllerId = (string)config["unique_id"];
 }
Example #4
0
        public static void Main(string[] args)
        {
            //Create a new instance of the plugin class
            _plugin = new HSPI();

            //Perform any initialization that needs to occur before a connection is made to HomeSeer

            //Attempt to connect to HomeSeer
            _plugin.Connect(args);
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
              {
            homeSeerApp = (hsapplication)Context.Items["Content"];

            // Used for debugging in VS
            if (homeSeerApp == null)
              homeSeerApp = Global.homeSeerApp;

            if (homeSeerApp == null)
              throw new Exception("Error loading HomeSeer application object");

            log = Log.GetInstance("HSPI_JJLATITUDE.Web.Distances", homeSeerApp);

            plugin = (HSPI)homeSeerApp.Plugin(App.PLUGIN_NAME);

            if (plugin == null)
              throw new Exception("Error getting a reference to the plug-in.  Is it loaded and enabled?");
              }
              catch (Exception ex)
              {
            Response.Write(ex.Message + ex.StackTrace);
              }
              log.Debug("Loading Distances web page");

              // Inject HomeSeer HTML
              litHSHeader.Text = HomeSeer.GetHeadContent(homeSeerApp);
              litHSBody.Text = HomeSeer.GetBodyContent(homeSeerApp);
              litHSFooter.Text = HomeSeer.GetFooterContent(homeSeerApp);

              dsPeople.DataFile = Db.DbPath;
              dsPlaces.DataFile = Db.DbPath;
              dsDistances.DataFile = Db.DbPath;

              if (!IsPostBack)
              {

              }
        }
Example #6
0
 public DeviceBundle(string address, HSPI plugin)
 {
     Address = address.Split('-')[0];
     _plugin = plugin;
 }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
              homeSeerApp = (hsapplication)Context.Items["Content"];

              // Used for debugging in VS
              if (homeSeerApp == null)
            homeSeerApp = Global.homeSeerApp;

              if (homeSeerApp == null)
            throw new Exception("Error loading HomeSeer application object");

              plugin = (HSPI)homeSeerApp.Plugin(App.PLUGIN_NAME);

              if (plugin == null)
            throw new Exception("Error getting a reference to the plug-in.  Is it loaded and enabled?");
            }
            catch (Exception ex)
            {
              Response.Write(ex.Message + ex.StackTrace);
            }
            log = Log.GetInstance("HSPI_JJLATITUDE.Web.Config", homeSeerApp);

              if (!IsPostBack)
            {

            log.Debug("Loading Config page");

            // Inject HomeSeer HTML
            litHSHeader.Text = HomeSeer.GetHeadContent(homeSeerApp);
            litHSBody.Text = HomeSeer.GetBodyContent(homeSeerApp);
            litHSFooter.Text = HomeSeer.GetFooterContent(homeSeerApp);

            try
            {
              lstLogLevel.SelectedValue = AppConfig.Read("Main", "LogLevel");
            }
            catch (Exception)
            {
              log.Error("Error reading config value: LogLevel");
            }

            try
            {
              lstUpdateFreq.SelectedValue = AppConfig.Read("Main", "UpdateFrequency");
            }
            catch (Exception)
            {
              log.Error("Error reading config value: UpdateFrequency");
            }

            try
            {
              chkLogFile.Checked = Convert.ToBoolean(AppConfig.Read("Main", "LogToFile"));
            }
            catch (Exception)
            {
              log.Error("Error reading config value: LogToFile");
            }

            try
            {
              chkLogHomeSeer.Checked = Convert.ToBoolean(AppConfig.Read("Main", "LogToHomeSeer"));
            }
            catch (Exception)
            {
              log.Error("Error reading config value: LogToHomeSeer");
            }

              }  // (!IsPostBack)
        }
Example #8
0
 public EnOceanManager(IHSApplication pHsHost, IAppCallbackAPI pHsCB, HSPI pHspiInst)
 {
     hspiInst = pHspiInst;
     HS       = pHsHost;
     HSCB     = pHsCB;
 }
 public EnOceanManager(IHSApplication pHsHost, IAppCallbackAPI pHsCB, HSPI pHspiInst)
 {
     hspiInst = pHspiInst;
     HS = pHsHost;
     HSCB = pHsCB;
 }
        public void run()
        {
            string[] cmdArgs = Environment.GetCommandLineArgs();
            Console.WriteLine("Manager::run() - arguments are {0}", Environment.CommandLine);
            String paramServer = "127.0.0.1";
            String paramInstance = "";
            foreach (string arg in cmdArgs)
            {
                Console.WriteLine(" - arg: {0}", arg);
                if (arg.Contains("="))
                {
                    String[] ArgS = arg.Split('=');
                    Console.WriteLine(" -- {0}=>{1}", ArgS[0], ArgS[1]);
                    switch (ArgS[0])
                    {
                        case "server":
                            paramServer = ArgS[1];
                            break;
                        case "instance":
                            paramInstance = ArgS[1];
                            break;
                        default:
                            Console.WriteLine("Unhandled param: {0}", ArgS[0]);
                            break;

                    }
                }
            }
            pluginInst = new HSPI(paramInstance);

            //Environment.CommandLine.
            client = ScsServiceClientBuilder.CreateClient<IHSApplication>(new ScsTcpEndPoint(paramServer, 10400), pluginInst);
            clientCB = ScsServiceClientBuilder.CreateClient<IAppCallbackAPI>(new ScsTcpEndPoint(paramServer, 10400), pluginInst);

            try
            {
                client.Connect();
                clientCB.Connect();
                hsHost = client.ServiceProxy;
                double ApiVer = hsHost.APIVersion;
                Console.WriteLine("Host ApiVersion : {0}", ApiVer);
                hsHostCB = clientCB.ServiceProxy;
                ApiVer = hsHostCB.APIVersion;
                Console.WriteLine("Host CB ApiVersion : {0}", ApiVer);
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot start instance because of : {0}", e.Message);
                return;
            }
            Console.WriteLine("Connection to HS succeeded!");
            try
            {
                pluginInst.hsHost = hsHost;
                pluginInst.hsHostCB = hsHostCB;
                hsHost.Connect(pluginInst.Name, "");
                Console.WriteLine("Connected, waiting to be initialized...");
                do
                {
                    Thread.Sleep(500);
                } while (client.CommunicationState == CommunicationStates.Connected && pluginInst.Running);

                Console.WriteLine("Connection lost, exiting");
                pluginInst.Running = false;

                client.Disconnect();
                clientCB.Disconnect();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to host connect: {0}", e.Message);
                return;
            }

            Console.WriteLine("Exiting!!!");
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // dispose managed resources
         pluginInst.Dispose();
         pluginInst = null;
     }
     // free native resources
 }