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

            string dummyDeviceId = moduleInfo.Args()[0];

            serialPortNameforArudino = moduleInfo.Args()[1];

            //.... Open the serial port - AJB TODO - error checking on port name
            serialPortOpen = OpenSerialPort();

            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform("arduino-" + dummyDeviceId);

            dummyPort = InitPort(portInfo);

            // ..... initialize the list of roles we are going to export and bind to the role
            List <VRole> listRole = new List <VRole>()
            {
                RoleDummy.Instance
            };

            BindRoles(dummyPort, listRole);

            //.................register the port after the binding is complete
            RegisterPortWithPlatform(dummyPort);

            workThread = new SafeThread(delegate() { Work(); }, "ArduinoDriverDummy work thread", logger);
            workThread.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Example #2
0
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            string dummyDevice = moduleInfo.Args()[0];

            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(dummyDevice);

            dummyPort = InitPort(portInfo);

            // ..... initialize the list of roles we are going to export and bind to the role
            List <VRole> listRole = new List <VRole>()
            {
                RoleProximitySensor.Instance
            };

            BindRoles(dummyPort, listRole);

            //.................register the port after the binding is complete
            RegisterPortWithPlatform(dummyPort);

            workThread = new SafeThread(delegate() { Work(); }, "DriverBLEProximity work thread", logger);
            workThread.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Example #3
0
        /// <summary>
        /// Method that will try to connect to all paired and configured devices.
        /// The connections are done async, in parallel threads to avoid waiting and time-outs.
        /// </summary>
        private void ConnectToPairedDevices()
        {
            //get all configured devices within LoT
            allPortsList = new List <VPort>();
            while (allPortsList.Count == 0)
            {
                allPortsList = GetAllPortsFromPlatform();
            }
            //match them with the paired ones. These lists can be different only if the driver failed for some reason.
            List <string> paired = new List <string>();

            foreach (VPort vp in allPortsList)
            {
                paired.Add(getDeviceAddressFromPort(vp));
            }
            foreach (string p in paired)
            {
                BluetoothDevice bd = Bluetooth.getDeviceByAddress(p, false);
                if (!bd.Connected || !Bluetooth.devicesStreams.Keys.Contains(bd))
                {
                    try {
                        //attempt to connect and add stream listener.
                        worker = new SafeThread(delegate() { Work(bd); }, "AppBluetoothListener-worker", logger);
                        worker.Start();
                    } catch (Exception e) {
                        logger.Log("Got exception in GetPairedDevices: " + e);
                        continue;
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Tries to start a connection with the "ThinkGearConnector" app.
        /// </summary>
        public override void Start()
        {
            //Try to connect to "ThinkGearConnector"
            try { client = new TcpClient("127.0.0.1", 13854); }
            catch { throw new Exception("You must install the \"ThinkGearConnector\" [http://developer.neurosky.com/docs/doku.php?id=thinkgear_connector_tgc]"); }

            logger.Log("Started: {0}", ToString());

            string mindWaveDevice = moduleInfo.Args()[0];

            //Instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(mindWaveDevice);

            mindWavePort = InitPort(portInfo);
            //Initialize the list of roles we are going to export and bind to the role
            List <VRole> listRole = new List <VRole>()
            {
                RoleMindWave.Instance
            };

            BindRoles(mindWavePort, listRole);
            //Register the port after the binding is complete
            RegisterPortWithPlatform(mindWavePort);

            workThread = new SafeThread(delegate() { Work(); }, "DriverMindWave work thread", logger);
            workThread.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Example #5
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            DummyService dummyService = new DummyService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IDummyContract), dummyService, 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
            accessibleDummyPorts = 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.CreateValueDataStream <StrKey, StrValue>("test", true /* remoteSync */);

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppDummy-worker", logger);
            worker.Start();
        }
Example #6
0
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            string airConditionCtrlDevice = moduleInfo.Args()[0];

            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(airConditionCtrlDevice);

            airConditionCtrlPort = InitPort(portInfo);

            // ..... initialize the list of roles we are going to export and bind to the role
            List <VRole> listRole = new List <VRole>()
            {
                RoleSwitchMultiLevel.Instance
            };

            BindRoles(airConditionCtrlPort, listRole);

            //.................register the port after the binding is complete
            RegisterPortWithPlatform(airConditionCtrlPort);

            workThread = new SafeThread(delegate() { Work(); }, "DriverAirConditionCtrl work thread", logger);
            workThread.Start();

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

            gm.ComPort  = "COM6";
            gm.BaudRate = 9600;
            gm.Open();
            gm.SmsRecieved += new EventHandler(gm_SmsRecieved);
        }
Example #7
0
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            try
            {
                string[] words = moduleInfo.Args();

                bridgeId   = words[0];
                bridgeUser = words[1];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            bridgeIp = GetBridgeIp(bridgeId);

            if (bridgeIp == null)
            {
                return;
            }

            lightManager = new LightsManager(bridgeIp, bridgeUser, logger);


            workThread = new SafeThread(delegate() { InitBridge(); }, "HueBridge init thread", logger);
            workThread.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Example #8
0
 public Minimap(IBot bot, int width, int height)
     : base(bot)
 {
     this.bot = bot;
     this.width = width;
     this.height = height;
     this.bitmap = new Bitmap(width, height);
     updateThread = new SafeThread(UpdateMinimap);
     updateThread.Start();
 }
Example #9
0
        private static void Main()
        {
            Config.Create("settings.ini");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var thread = new SafeThread(Run);

            thread.OnException += HandleException;
            thread.Start();
        }
Example #10
0
        private void UpdateConfigConnectStateOPCUA(ConfigConnectStateOPCUA state)
        {
            switch (state)
            {
            case ConfigConnectStateOPCUA.ConnectEstablish:
                SafeThread.SetImageStripItem(statusbar, statusConnectOPCUALabel, Resources.OK);
                break;

            case ConfigConnectStateOPCUA.Connecting:
                SafeThread.SetImageStripItem(statusbar, statusConnectOPCUALabel, Resources.Critical_Blink);
                break;
            }
        }
Example #11
0
        public Room(IBot bot)
            : base(bot)
        {
            this.bot = bot;
            this.blockMap = new BlockMap(bot);
            this.blockDrawerPool = new BlockDrawerPool(bot, this);
            this.blockDrawer = blockDrawerPool.CreateBlockDrawer(15);
            this.blockDrawer.Start();

            playerTickThread = new SafeThread(UpdatePhysics);

            EnableTick(50);
        }
Example #12
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            BluetoothAppService bluetoothService = new BluetoothAppService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IBluetoothAppContract), bluetoothService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();
            //create the app server
            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
            //Create a new thread that will try connect to all configured device asynchroniously every 10 sec
            worker = new SafeThread(delegate() { tryConnectToDevices(); }, "AppBluetoothPing-worker", logger);
            worker.Start();
        }
        private void RecAudio(int recLength)
        {
            if (!Directory.Exists("..\\KinectAudios\\"))
            {
                DirectoryInfo di = Directory.CreateDirectory("..\\KinectAudios\\");
                logger.Log("New directory created to store audio files at {0}.", di.FullName);
            }

            lastAudioClipName = "..\\KinectAudios\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_wav.wav";
            worker            = new SafeThread(delegate()
            {
                AudioRecording(recLength);
            }, "DriverKinect-RecAudio", logger);
            worker.Start();
            logger.Log("Audio Recording Started.");
        }
Example #14
0
 private void UpdateConfigState(ConfigState state)
 {
     if (state == ConfigState.Stopped)
     {
         SafeThread.SetEnableControl(textOPCNodeName, true);
         SafeThread.SetEnableControl(nudOPCUpdateRate, true);
         SafeThread.SetEnableControl(btnApply, true);
         SafeThread.SetEnableControl(btnTest, true);
     }
     else
     {
         SafeThread.SetEnableControl(textOPCNodeName, false);
         SafeThread.SetEnableControl(nudOPCUpdateRate, false);
         SafeThread.SetEnableControl(btnApply, false);
         SafeThread.SetEnableControl(btnTest, false);
     }
 }
        protected override void WorkerThread()
        {
            logger.Log("Started: {0}", this.ToString());


            try
            {
                string[] words = moduleInfo.Args();

                deviceId = words[0];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            deviceIp = GetDeviceIp(deviceId);

            if (deviceIp == null)
            {
                logger.Log("{0} did not get a device ip for deviceId: {1}. Returning", base.moduleInfo.BinaryName(), deviceId.ToString());
                return;
            }

            //add the service port
            ///AJB - how do we know it's a couch?
            VPortInfo pInfo = GetPortInfoFromPlatform("gadgeteer-" + deviceId);

            RoleCouch roleCouch = RoleCouch.Instance;

            List <VRole> roles = new List <VRole>();

            roles.Add(roleCouch);

            devicePort = InitPort(pInfo);
            BindRoles(devicePort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(devicePort);
            worker = new SafeThread(delegate()
            {
                PollDevice();
            }, "DriverGadgeteerMSREmotoCouch-PollDevice", logger);
            worker.Start();
        }
        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();
        }
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            AirConditionCtrlService airConditionCtrlService = new AirConditionCtrlService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IAirConditionCtrlContract), airConditionCtrlService, 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
            accessibleAirConditionCtrlPorts = new List <VPort>();

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

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

            receivedMessageList = new List <string>();

            readMsgByIdList = new List <string>();
            rcvdNewMsgList  = 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 */);

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


            //gm.ComPort = "COM6";
            //gm.BaudRate = 9600;
            //gm.Open();


            //gm.SmsRecieved += new EventHandler(gm_SmsRecieved);
        }
 private void UpdateConfigState(ConfigState state)
 {
     if (state == ConfigState.Stopped)
     {
         SafeThread.SetEnableControl(btnApply, true);
         SafeThread.SetEnableControl(btnTest, true);
         SafeThread.SetEnableControl(comboBoxDSN, true);
         SafeThread.SetEnableControl(textBoxUserName, true);
         SafeThread.SetEnableControl(textBoxPassword, true);
     }
     else
     {
         SafeThread.SetEnableControl(btnApply, false);
         SafeThread.SetEnableControl(btnTest, false);
         SafeThread.SetEnableControl(comboBoxDSN, false);
         SafeThread.SetEnableControl(textBoxUserName, false);
         SafeThread.SetEnableControl(textBoxPassword, false);
     }
 }
 private void UpdateConfigState(ConfigState state)
 {
     if (state == ConfigState.Stopped)
     {
         SafeThread.SetEnableControl(btnApply, true);
         SafeThread.SetReadOnlyDataGridView(dataGridTrn, false);
         SafeThread.SetAllowUserToAddRowsDataGridView(dataGridTrn, true);
         SafeThread.SetVisibleStripItem(navigatorTran, navigatorAddNewItem, true);
         SafeThread.SetVisibleStripItem(navigatorTran, navigatorDeleteItem, true);
     }
     else
     {
         SafeThread.SetEnableControl(btnApply, false);
         SafeThread.CancelEditDataGridView(dataGridTrn);
         SafeThread.SetReadOnlyDataGridView(dataGridTrn, true);
         SafeThread.SetAllowUserToAddRowsDataGridView(dataGridTrn, false);
         SafeThread.SetVisibleStripItem(navigatorTran, navigatorAddNewItem, false);
         SafeThread.SetVisibleStripItem(navigatorTran, navigatorDeleteItem, false);
     }
 }
Example #20
0
        private void UpdateConfigStateOPCUA(ConfigStateOPCUA state)
        {
            trayNotifyIcon.Text = Application.ProductName + " - " + state.ToString();
            SafeThread.SetTextStripItem(statusbar, statusConfigLabel, "Configuration state: " + state.ToString());
            switch (state)
            {
            case ConfigStateOPCUA.Started:
                trayNotifyIcon.Text = Application.ProductName + " - OPCUA" + " - " + state.ToString();
                trayNotifyIcon.Icon = Properties.Resources.servicerunning;
                SafeThread.SetImageStripItem(statusbar, statusConfigLabel, Resources.Run);
                SafeThread.SetEnableStripItem(toolbar, startOPCUAButton, false);
                SafeThread.SetEnableStripItem(menu, startOPCUAMenuItem, false);
                SafeThread.SetEnableStripItem(trayMenu, startOPCUATrayMenuItem, false);
                SafeThread.SetEnableStripItem(toolbar, stopOPCUAButton, true);
                SafeThread.SetEnableStripItem(menu, stopOPCUAMenuItem, true);
                SafeThread.SetEnableStripItem(trayMenu, stopOPCUATrayMenuItem, true);
                break;

            case ConfigStateOPCUA.Stopped:
                trayNotifyIcon.Text = Application.ProductName + " - OPCUA" + " - " + state.ToString();
                trayNotifyIcon.Icon = Properties.Resources.servicestopped;
                SafeThread.SetImageStripItem(statusbar, statusConfigLabel, Resources.Stop);
                if (Config.ReadyOPCUA)
                {
                    SafeThread.SetEnableStripItem(toolbar, startOPCUAButton, true);
                    SafeThread.SetEnableStripItem(menu, startOPCUAMenuItem, true);
                    SafeThread.SetEnableStripItem(trayMenu, startOPCUATrayMenuItem, true);
                }
                else
                {
                    SafeThread.SetEnableStripItem(toolbar, startOPCUAButton, false);
                    SafeThread.SetEnableStripItem(menu, startOPCUAMenuItem, false);
                    SafeThread.SetEnableStripItem(trayMenu, startOPCUATrayMenuItem, false);
                }
                SafeThread.SetEnableStripItem(toolbar, stopOPCUAButton, false);
                SafeThread.SetEnableStripItem(menu, stopOPCUAMenuItem, false);
                SafeThread.SetEnableStripItem(trayMenu, stopOPCUATrayMenuItem, false);
                break;
            }
        }
Example #21
0
        public override void Start()
        {
            try
            {
                string[] words = moduleInfo.Args();

                deviceId = words[0];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            deviceIp = GetDeviceIp(deviceId);

            if (deviceIp == null)
            {
                logger.Log("{0} did not get a device ip for deviceId: {1}. Returning", base.moduleInfo.BinaryName(), deviceId.ToString());
                return;
            }

            //add the service port
            VPortInfo pInfo = GetPortInfoFromPlatform("gadgeteer-" + deviceId);

            devicePort = InitPort(pInfo);

            // add role and register with platform
            BindRoles(devicePort, GetRoleList(), OnOperationInvoke);
            RegisterPortWithPlatform(devicePort);

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

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Example #22
0
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            string deviceName      = moduleInfo.Args()[0];
            string deviceAddress   = moduleInfo.Args()[1];
            string deviceClassType = moduleInfo.Args()[2];
            string deviceType      = moduleInfo.Args()[3];

            //try pair with the device.
            bool pair = tryPairWithDevice(deviceAddress, deviceType);

            if (!pair)
            {
                //think of something
            }
            else
            {
                logger.Log("Bluetooth Driver: Paired with \"" + deviceName + " - " + deviceAddress + "\"");
            }
            //init the port
            VPortInfo portInfo = GetPortInfoFromPlatform(deviceName);

            bluetoothPort = InitPort(portInfo);

            //init the role
            List <VRole> listRole = new List <VRole>()
            {
                RoleBluetooth.Instance
            };

            BindRoles(bluetoothPort, listRole);

            //register the port
            RegisterPortWithPlatform(bluetoothPort);

            workThread = new SafeThread(delegate() { Work(); }, "DriverBluetooth work thread", logger);
            workThread.Start();
        }
Example #23
0
        void RefreshDbs(object sender, System.Timers.ElapsedEventArgs e)
        {
            //refresh Dbs in the background
            SafeThread refreshThread = new SafeThread(delegate()
            {
                logger.Log("Homestore refresh was triggered");

                //refresh into this temporary db
                HomeStoreDb tmpStoreDb = new HomeStoreDb(logger);
                tmpStoreDb.Populate();

                //do a switch now
                lock (this)
                {
                    storeDb = tmpStoreDb;
                }

                lastRefreshed = DateTime.Now;
            }, "homestore refresh", logger);

            refreshThread.Start();
        }
Example #24
0
        private void StopRecording(VPort cameraPort, bool force)
        {
            bool       stopConditionMet = false;
            CameraInfo cameraInfo       = registeredCameras[cameraPort];

            //if ((DateTime.Now - registeredCameras[cameraPort].CurrVideoStartTime).TotalMinutes >=
            //            MAX_VIDEO_CLIP_LEN_IN_MINUTES)

            if (DateTime.Now >= registeredCameras[cameraPort].CurrVideoEndTime)
            {
                stopConditionMet = true;
            }

            if ((force || stopConditionMet) && (cameraInfo.VideoWriter != null))
            {
                string      cameraName  = cameraPort.GetInfo().GetFriendlyName();
                VideoWriter VideoWriter = cameraInfo.VideoWriter;

                SafeThread helper = new SafeThread(delegate() { StopRecordingHelper(VideoWriter, cameraName); },
                                                   "stoprecordinghelper-" + cameraName, logger);
                helper.Start();

                cameraInfo.RecordVideo        = false;
                cameraInfo.VideoWriter        = null;
                cameraInfo.CurrVideoStartTime = DateTime.MinValue;
                cameraInfo.CurrVideoEndTime   = DateTime.MinValue;

                if (stopConditionMet)
                {
                    logger.Log("Stop recording because the clip time has elapsed for {0}",
                               cameraPort.GetInfo().GetFriendlyName());
                }
                else
                {
                    logger.Log("Stop recording for {0}", cameraPort.GetInfo().GetFriendlyName());
                }
            }
        }
Example #25
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            DoorjambService simplexService = new DoorjambService(logger, this);

            simplexServiceHost = DoorjambService.CreateServiceHost(logger, this, simplexService, moduleInfo.BaseURL() + "/webapp");

            simplexServiceHost.Open();

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


            //........... instantiate the list of other ports that we are interested in
            accessibleDoorjambPorts = 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>();
            this.irDataList          = new List <string>();
            this.irDataList.Add("");
            this.usDataList = new List <string>();
            this.usDataList.Add("");
            this.eventTime = "";

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppDoorjamb-worker", logger);
            worker.Start();
        }
Example #26
0
        public override void Start()
        {
            string[] words = moduleInfo.Args();
            video_dir = words[0];
            //video_filename = words[1];

            //add the camera service port
            VPortInfo pInfo = GetPortInfoFromPlatform("video loading");

            List <VRole> roles = new List <VRole>()
            {
                RoleCamera.Instance
            };

            cameraPort = InitPort(pInfo);
            BindRoles(cameraPort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(cameraPort);
            worker = new SafeThread(delegate()
            {
                GetVideo();
            }, "DriverVideoLoading-PollDevice", logger);
            worker.Start();
        }
Example #27
0
        private void InitCamera(CameraFrameSource frameSource)
        {
            logger.Log("Init-ing camera {0}", _frameSource.Camera.ToString());

            //add the camera service port if we haven't done that already
            if (cameraPort == null)
            {
                VPortInfo pInfo = GetPortInfoFromPlatform("webcam - " + cameraStr);

                List <VRole> roles = new List <VRole>()
                {
                    RoleCamera.Instance
                };

                cameraPort = InitPort(pInfo);
                BindRoles(cameraPort, roles, OnOperationInvoke);

                RegisterPortWithPlatform(cameraPort);
            }

            SafeThread worker = new SafeThread(delegate() { GetVideo(); }, "DriverWebCam-GetVideo", logger);

            worker.Start();
        }
        public override void Start()
        {
            string embedDriverArgs = moduleInfo.Args()[0];
            string comPortName     = embedDriverArgs;

            if (!String.IsNullOrEmpty(comPortName))
            {
                if (comPortName.Contains(MBED))
                {
                    comPortName = comPortName.Replace(MBED + " - ", "");
                }
                this.portName = comPortName;
            }
            connectionChecker = new SafeThread(delegate() { CheckComConnection(); }, "ComPort connection-checker", logger);
            if (InitializePort() == true)
            {
                try
                {
                    serialPort.Open();
                    connectionChecker.Start();
                    while (!connectionChecker.IsAlive())
                    {
                        ;
                    }
                }
                catch (Exception)
                {
                    List <COMPortFinder> comportList = COMPortFinder.GetCOMPortsInfo();

                    foreach (COMPortFinder comPortInfo in comportList)
                    {
                        if (comPortInfo.Description.Contains(MBED))
                        {
                            this.portName = comPortInfo.Name;
                            break;
                        }
                    }
                    InitializePort();
                    //serialPort.Open();
                }

                //testPort();
            }


            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(embedDriverArgs);

            mbedPort = InitPort(portInfo);

            // ..... initialize the list of roles we are going to export and bind to the role
            List <VRole> listRole = new List <VRole>()
            {
                RoleMbedSoftUps.Instance
            };

            BindRoles(mbedPort, listRole);

            //.................register the port after the binding is complete
            RegisterPortWithPlatform(mbedPort);
        }
 public BlockDrawerPool(IBot bot, IRoom room)
 {
     this.bot = bot;
     this.room = room;
     drawerThread = new SafeThread(Draw);
 }
Example #30
0
        public override void Start()
        {
            worker1    = null;
            worker2    = null;
            _mjpeg     = null;
            fileToRead = Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName() + "\\logo-green.jpg";

            try
            {
                string[] words = moduleInfo.Args();

                cameraId   = words[0];
                cameraUser = words[1];
                cameraPwd  = words[2];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }


            //get the IP address
            cameraIp = GetCameraIp(cameraId);

            if (cameraIp == null)
            {
                return;
            }

            //check the username and password
            cameraCredential = new NetworkCredential(cameraUser, cameraPwd);

            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(CameraUrl);
                webRequest.Credentials = cameraCredential;
                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                if (webResponse.StatusCode == HttpStatusCode.Unauthorized)
                {
                    logger.Log("{0} credentials ({1}/{2}) are not correct", this.ToString(), cameraUser, cameraPwd);
                    return;
                }

                logger.Log("Started: {0} with response code {1}", ToString(), webResponse.StatusCode.ToString());
                webResponse.Close();
            }
            catch (Exception e)
            {
                logger.Log("{0}: couldn't talk to the camera. are the arguments correct?\n exception details: {1}", this.ToString(), e.ToString());

                //don't return. maybe the camera will come online later
                //return;
            }

            //add the camera service port
            VPortInfo pInfo = GetPortInfoFromPlatform("foscam-" + cameraId);

            //List<VRole> roles = new List<VRole>() {RoleCamera.Instance, RolePTCamera.Instance};
            List <VRole> roles = new List <VRole>()
            {
                RolePTCamera.Instance
            };

            cameraPort = InitPort(pInfo);
            BindRoles(cameraPort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(cameraPort);


            switch (videoFetchMode)
            {
            case VideoFetchMode.SelfParse:
                worker1 = new SafeThread(delegate()
                {
                    GetVideoSelfParse();
                }, "GetVideoSelfParse", logger);
                worker1.Start();
                break;

            case VideoFetchMode.FromFile:
                worker2 = new SafeThread(delegate()
                {
                    GetVideoFromFile();
                }, "GetVideoFromFile", logger);
                worker2.Start();
                break;

            case VideoFetchMode.MjpegDecoder:
                GetVideoMjpegDecoder();
                break;

            default:
                logger.Log("Unknown video fetching mode");
                break;
            }

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
        public void ShowWindow()
        {
            SafeThread thread = new SafeThread(
                delegate()
                {
                    logWindow = new LogWindow(this, logger, moduleInfo.FriendlyName());
                    logWindow.ShowDialog();
                },
                "Launching window for " + ToString(),
                logger);

            thread.SetApartmentState(System.Threading.ApartmentState.STA);
            thread.Start();
        }
Example #32
0
        public override void Start()
        {
            try
            {
                string[] words = moduleInfo.Args();

                cameraId   = words[0];
                cameraUser = words[1];
                cameraPwd  = words[2];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            cameraIp = GetCameraIp(cameraId);

            if (cameraIp == null)
            {
                return;
            }


            cameraCredential = new NetworkCredential(cameraUser, cameraPwd);

            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(CameraUrl);
                webRequest.Credentials = cameraCredential;
                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                if (webResponse.StatusCode == HttpStatusCode.Unauthorized)
                {
                    logger.Log("{0} credentials ({1}/{2}) are not correct", this.ToString(), cameraUser, cameraPwd);
                    return;
                }

                logger.Log("Started: {0} with response code {1}", ToString(), webResponse.StatusCode.ToString());
                webResponse.Close();
            }
            catch (Exception e)
            {
                logger.Log("{0}: couldn't talk to the camera. are the arguments correct?\n exception details: {1}", this.ToString(), e.ToString());

                //don't return. maybe the camera will come online later
                //return;
            }

            //add the camera service port
            VPortInfo pInfo = GetPortInfoFromPlatform("axiscamera-" + cameraId);

            List <VRole> roles = CameraRoles(cameraId);

            cameraPort = InitPort(pInfo);
            BindRoles(cameraPort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(cameraPort);

            worker = new SafeThread(delegate()
            {
                GetVideo();
            }, "", logger);
            worker.Start();

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