예제 #1
0
        public void Connect(string serverAddress, int serverPort)
        {
            hsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>(
                new ScsTcpEndPoint(serverAddress, serverPort), this);
            hsClient.Connect();

            hs = hsClient.ServiceProxy;
            Program.HsClient = hs;
            // make sure we're connected successfully
            double apiVersion = hs.APIVersion;

            callbackClient =
                ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverAddress, serverPort),
                                                                       this);
            callbackClient.Connect();
            callbacks  = callbackClient.ServiceProxy;
            apiVersion = callbacks.APIVersion;

            hs.Connect(this.Name, this.InstanceFriendlyName());
        }
예제 #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Connects to Homeseer at the specified server address and port.
        /// This is called by the console wrapper.
        /// </summary>
        /// <param name="serverAddress">The server address.</param>
        /// <param name="serverPort">The server port.</param>
        /// <exception cref="Exception"> Error connecting homeseer SCS client </exception>
        /// <exception cref="Exception"> Error connecting callback SCS client </exception>
        /// <exception cref="Exception"> Error connecting homeseer to our plugin </exception>
        public virtual void Connect(string serverAddress, int serverPort)
        {
            // Create our main connection to the homeseer TCP communication framework
            // part 1 - hs object Proxy
            try
            {
                hsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverAddress, serverPort), this);
                hsClient.Connect();
                hs = hsClient.ServiceProxy;
                double APIVersion = hs.APIVersion;          // just to make sure our connection is valid
            }
            catch (Exception ex)
            {
                throw new Exception("Error connecting homeseer SCS client: " + ex.Message, ex);
            }

            // part 2 - callback object Proxy
            try
            {
                callbackClient = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverAddress, serverPort), this);
                callbackClient.Connect();
                callback = callbackClient.ServiceProxy;
                double APIVersion = callback.APIVersion;    // just to make sure our connection is valid
            }
            catch (Exception ex)
            {
                throw new Exception("Error connecting callback SCS client: " + ex.Message, ex);
            }

            // Establish the reverse connection from homeseer back to our plugin
            try
            {
                hs.Connect(IFACE_NAME, INSTANCE_NAME);
            }
            catch (Exception ex)
            {
                throw new Exception("Error connecting homeseer to our plugin: " + ex.Message, ex);
            }
        }
예제 #3
0
        public InstanceHolder(HSPI HSPI, HSCF.Communication.ScsServices.Client.IScsServiceClient <IHSApplication> Client, HomeSeerAPI.IAppCallbackAPI ClientCallback, HomeSeerAPI.IHSApplication Host, string Name)
        {
            name = Name;
            hspi = HSPI;
            hspi.OurInstanceFriendlyName = name;
            ajaxName = name;
            if (name != "")
            {
                ajaxName = ":" + name;
            }
            client   = Client;
            callback = ClientCallback;
            host     = Host;
            Devices  = GetDevices(this);


            modPage = new ModbusDevicePage("ModbusDevicePage", this);
            scrPage = new ScratchpadDevicePage("ScratchpadPage", this);
            modAjax = new MosbusAjaxReceivers(this);


            bacnetDevices         = new BACnetDevices(BACnetDevices.BaseUrl, this);
            bacnetDataService     = new BACnetDataService(BACnetDataService.BaseUrl, this);
            bacnetHomeSeerDevices = new BACnetHomeSeerDevices(BACnetHomeSeerDevices.BaseUrl, this);


            siidPage = new SIID_Page(Util.IFACE_NAME, this);

            //bacnetDevices = new BACnetDevices(BACnetDataService.BaseUrl + this.ajaxName.Replace(":", "_"), this);
            //bacnetDataService = new BACnetDataService(BACnetDataService.BaseUrl + this.ajaxName.Replace(":", "_"), this);
            //bacnetHomeSeerDevices = new BACnetHomeSeerDevices(BACnetHomeSeerDevices.BaseUrl + this.ajaxName.Replace(":", "_"), this);



            //CPU use is high, so try to minimize iterating through devices
            //Also minimize calls to and from the device's plugin extra data store. Keep parallel copy, maybe only update when change
        }