Exemplo n.º 1
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            PowerMeterService powermeterService = new PowerMeterService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IPowerMeterContract), powermeterService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessiblePowerMeterPorts = new List <VPort>();

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                ProcessAllPortsList(allPortsList);
            }

            this.receivedMessageList = new List <string>();

            // remoteSync flag can be set to true, if the Platform Settings has the Cloud storage
            // information i.e., DataStoreAccountName, DataStoreAccountKey values
            datastream = base.CreateFileStream <StrKey, StrValue>("dumb", false /* remoteSync */);


            //you can change SerialportName:"COM3",Maybe yours is not "COM3"
            foreach (VPort port in accessiblePowerMeterPorts)
            {
                Invoke(port, RolePowerMeter.Instance, RolePowerMeter.OpOpenSerialPort, new ParamType(ParamType.SimpleType.text, "SerialPortName", "COM3"));
            }

            SendCommand("status");

            GetAllPowerMeterStatus();

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppPowerMeter-worker", logger);
            worker.Start();
        }
Exemplo n.º 2
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            PowerMeterService powermeterService = new PowerMeterService(logger, this);
            serviceHost = new SafeServiceHost(logger, typeof(IPowerMeterContract), powermeterService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessiblePowerMeterPorts = new List<VPort>();

            //..... get the list of current ports from the platform
            IList<VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
                ProcessAllPortsList(allPortsList);

            this.receivedMessageList = new List<string>();

            // remoteSync flag can be set to true, if the Platform Settings has the Cloud storage
            // information i.e., DataStoreAccountName, DataStoreAccountKey values
            datastream = base.CreateFileStream<StrKey, StrValue>("dumb", false /* remoteSync */);

            
            //you can change SerialportName:"COM3",Maybe yours is not "COM3"
            foreach (VPort port in accessiblePowerMeterPorts)
            {

              Invoke(port, RolePowerMeter.Instance, RolePowerMeter.OpOpenSerialPort, new ParamType(ParamType.SimpleType.text, "SerialPortName", "COM3"));
            }

            SendCommand("status");

            GetAllPowerMeterStatus();

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppPowerMeter-worker", logger);
            worker.Start();

        }