예제 #1
0
        private void Run()
        {
            #region Initialize sensor
            // Get an instance of the sensor class using the assembly and class names.
            //SensorInterface = InterfaceFactory.CreateSensorInstance("Scallop.Sensor.FileSource.dll");
            SensorInterface = InterfaceFactory.CreateSensorInstance("Scallop.Sensor.Axis.dll");

            // Define the handler functions
            SensorInterface.Data          += new EventHandler <ScallopSensorDataEventArgs>(SensorInterface_Data);
            SensorInterface.StatusChanged += new EventHandler <ScallopSensorStatusChangedEventArgs>(SensorInterface_StatusChanged);
            SensorInterface.Info          += new EventHandler <ScallopInfoEventArgs>(SensorInterface_Info);

            // Configure the sensor interface with parameters from an XML file.
            SensorInterface.Register(XDocument.Load(SensorConfigFile), null);
            #endregion

            #region Initialize network
            // Get instance of network class.
            NetworkInterface = InterfaceFactory.CreateNetworkInstance("Scallop.Network.PeerChannel.dll");

            // Define handler functions.
            NetworkInterface.Data          += new EventHandler <ScallopNetworkDataEventArgs>(NetworkInterface_Data);
            NetworkInterface.StatusChanged += new EventHandler <ScallopNetworkStatusChangedEventArgs>(NetworkInterface_StatusChanged);
            NetworkInterface.Info          += new EventHandler <ScallopInfoEventArgs>(NetworkInterface_Info);
            #endregion

            // Start sensor.
            SensorInterface.Start();
            // Join network.
            System.Xml.XmlDocument NetworkConfig = new System.Xml.XmlDocument();
            NetworkConfig.Load(NetworkConfigFile);
            NetworkInterface.Join(NetworkConfig, null);

            waitEvent.WaitOne();
        }
예제 #2
0
        static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
        {
            if (SensorInterface != null)
            SensorInterface.Dispose();

             if (NetworkInterface != null)
            NetworkInterface.Dispose();

             SensorInterface = null;
             NetworkInterface = null;
        }
예제 #3
0
        static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
        {
            if (SensorInterface != null)
            {
                SensorInterface.Dispose();
            }

            if (NetworkInterface != null)
            {
                NetworkInterface.Dispose();
            }

            SensorInterface  = null;
            NetworkInterface = null;
        }
예제 #4
0
        private void Run()
        {
            #region Initialize sensor
             // Get an instance of the sensor class using the assembly and class names.
             //SensorInterface = InterfaceFactory.CreateSensorInstance("Scallop.Sensor.FileSource.dll");
             SensorInterface = InterfaceFactory.CreateSensorInstance("Scallop.Sensor.Axis.dll");

             // Define the handler functions
             SensorInterface.Data += new EventHandler<ScallopSensorDataEventArgs>(SensorInterface_Data);
             SensorInterface.StatusChanged += new EventHandler<ScallopSensorStatusChangedEventArgs>(SensorInterface_StatusChanged);
             SensorInterface.Info += new EventHandler<ScallopInfoEventArgs>(SensorInterface_Info);

             // Configure the sensor interface with parameters from an XML file.
             SensorInterface.Register(XDocument.Load(SensorConfigFile), null);
             #endregion

             #region Initialize network
             // Get instance of network class.
             NetworkInterface = InterfaceFactory.CreateNetworkInstance("Scallop.Network.PeerChannel.dll");

             // Define handler functions.
             NetworkInterface.Data += new EventHandler<ScallopNetworkDataEventArgs>(NetworkInterface_Data);
             NetworkInterface.StatusChanged += new EventHandler<ScallopNetworkStatusChangedEventArgs>(NetworkInterface_StatusChanged);
             NetworkInterface.Info += new EventHandler<ScallopInfoEventArgs>(NetworkInterface_Info);
             #endregion

             // Start sensor.
             SensorInterface.Start();
             // Join network.
             System.Xml.XmlDocument NetworkConfig = new System.Xml.XmlDocument();
             NetworkConfig.Load(NetworkConfigFile);
             NetworkInterface.Join(NetworkConfig, null);

             do
             {
            // infinite loop
            System.Threading.Thread.Sleep(1000);
             } while (true);
        }