Beispiel #1
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);
        }
        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
            PortName = GetDevicePort(deviceId);
            logger.Log("Got a port name of {0}", new string[] { PortName });

            if (PortName == 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("valve-" + deviceId);

            devicePort = InitPort(pInfo);

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

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
        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);
        }
        public override void Start()
        {
            // ..... initialize the list of roles we are going to export
            List <VRole> listRole = new List <VRole>()
            {
                RoleDoorjamb.Instance
            };

            //.................instantiate the port
            //grab the specific device name
            doorjambDeviceName = moduleInfo.Args()[0];
            VPortInfo portInfo = GetPortInfoFromPlatform("" + doorjambDeviceName);

            doorjambPort = InitPort(portInfo);

            //..... bind the port to roles and delegates
            BindRoles(doorjambPort, listRole, OnOperationInvoke);

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

            GetDataPort();
            ListenForData();

            Thread.Sleep(Timeout.Infinite);
        }
Beispiel #5
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

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

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

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

            BindRoles(powermeterPort, listRole);

            //Register the port after the binding is complete
            RegisterPortWithPlatform(powermeterPort);

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


            System.Threading.Thread.Sleep(1 * 10 * 1000);
        }
Beispiel #6
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);
        }
        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);
        }
Beispiel #8
0
        /// <summary>
        /// Get device Type from VPort
        /// </summary>
        /// <param name="vp"></param>
        /// <returns></returns>
        private String getDeviceTypeFromPort(VPort vp)
        {
            VPortInfo vpi     = vp.GetInfo();
            string    address = vpi.ModuleFacingName();

            string[] split = address.Split('|');
            address = split[split.Length - 3].ToString();
            address = address.Trim();
            return(address);
        }
Beispiel #9
0
 internal static IPortInfo V2C(VPortInfo view)
 {
     if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(view) &&
         (view.GetType().Equals(typeof(PortInfoC2V))))
     {
         return(((PortInfoC2V)(view)).GetSourceContract());
     }
     else
     {
         return(new PortInfoV2C(view));
     }
 }
Beispiel #10
0
        /// <summary>
        /// Initializes the port given the portinfo
        /// </summary>
        /// <param name="portInfo">The portinfo for the port</param>
        /// <returns>The initialized port</returns>
        protected Port InitPort(VPortInfo portInfo)
        {
            Port       port       = new Port(portInfo, this, PortStatus.Available, logger, OnNotification);
            Capability capability = new Capability(moduleInfo.FriendlyName(), DateTime.MaxValue);

            lock (myPorts)
            {
                myPorts.Add(port);
            }

            defaultPortCapabilities[port] = capability;

            port.AddCapability(capability);

            return(port);
        }
        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();
        }
Beispiel #12
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);
        }
Beispiel #13
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();
        }
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            List <COMPortInfo> comportList = COMPortInfo.GetCOMPortsInfo();

            foreach (COMPortInfo comPortInfo in comportList)
            {
                if (comPortInfo.Description.Contains(Prolific))
                {
                    this.SerialPortName = comPortInfo.Name;
                    break;
                }
            }
            logger.Log("Discovered envi sensor on COM port: " + SerialPortName);


            // ..... initialize the list of roles we are going to export
            List <VRole> listRole = new List <VRole>()
            {
                RoleSensorMultiLevel.Instance
            };
            //AJ add the other roles - like temperature into this list and then below do notifications on them
            //List<VRole> listRole = new List<VRole>() { RoleSensor.Instance };

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

            enviPort = InitPort(portInfo);

            //..... bind the port to roles and delegates
            BindRoles(enviPort, listRole, null);

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

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

            //sanity check and recover the parameters
            if (moduleInfo.Args().Count() != 4)
            {
                logger.Log("DriverOwm: incorrect number of parameters: {0}", moduleInfo.Args().Count().ToString());
                return;
            }

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

            appId     = moduleInfo.Args()[1];
            lattitude = moduleInfo.Args()[2];
            longitude = moduleInfo.Args()[3];

            latestWeather = new WeatherData();

            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform("owm-" + deviceId);

            weatherPort = InitPort(portInfo);

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

            BindRoles(weatherPort, listRole);

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

            timer = new Timer(GetWeather, null, 0, WeatherFetchPeriodMs);
        }
        public override void Start()
        {
            string kinectStr = moduleInfo.Args()[0];

            foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {
                    //encode the id string as per the encoding in the scout so the match will work
                    // '\' and '&' cause problem when the values get written to the config file (XML writer not happy)
                    string kinectid = "Kinect Sensor:" + potentialSensor.UniqueKinectId.Replace("\\", "-").Replace("&", ".");
                    if (kinectStr == kinectid)
                    {
                        this.sensor = potentialSensor;
                        break;
                    }
                }
            }

            //Create a new port on the platform.

            VPortInfo    pInfo = GetPortInfoFromPlatform("kinect" + kinectStr);
            List <VRole> roles = new List <VRole>()
            {
                RoleCamera.Instance, RoleDepthCam.Instance, RoleMicrophone.Instance, RoleSkeletonTracker.Instance, RoleSpeechReco.Instance
            };

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

            RegisterPortWithPlatform(kinectPort);


            logger.Log("Kinect Sensor Registered.");
            StartKinect();
        }
Beispiel #17
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();
        }
Beispiel #18
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();
        }
Beispiel #19
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);
        }
Beispiel #20
0
 public PortInfoV2C(VPortInfo view)
 {
     _view = view;
 }
        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);
        }
Beispiel #22
0
 public void SetRoles(VPortInfo portInfo, IList <VRole> roles, VModule module)
 {
     _contract.SetRoles(PortInfoAdapter.V2C(portInfo),
                        CollectionAdapters.ToIListContract <VRole, IRole>(roles, RoleAdapter.V2C, RoleAdapter.C2V),
                        ModuleAdapter.V2C(module));
 }
Beispiel #23
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);
        }