Exemplo n.º 1
0
 public TempSensor(string thingPropertiesURI)
 {
     DataRiver = DataRiver.GetInstance();
     Thing     = CreateThing(DataRiver, thingPropertiesURI);
     Stop      = false;
     Console.CancelKeyPress += this.CtrlCHandler;
     Console.WriteLine("Temperature Sensor started");
 }
 public ThroughputReader()
 {
     DataRiver = DataRiver.GetInstance();
     Thing     = CreateThing(DataRiver);
     Stop      = false;
     Console.CancelKeyPress += this.CtrlCHandler;
     Console.WriteLine("Throughput reader started");
 }
Exemplo n.º 3
0
 public Ping(string thingPropertiesURI)
 {
     DataRiver               = DataRiver.GetInstance();
     Thing                   = CreateThing(DataRiver, thingPropertiesURI);
     SampleData              = new IotNvpSeq();
     Stop                    = false;
     Console.CancelKeyPress += this.CtrlCHandler;
     Console.WriteLine("# Ping started");
 }
Exemplo n.º 4
0
 public Dashboard(string thingPropertiesURI)
 {
     DataRiver = DataRiver.GetInstance();
     Thing     = CreateThing(DataRiver, thingPropertiesURI);
     Stop      = false;
     TruckData = new Dictionary <string, TruckDataValue>();
     Console.CancelKeyPress += this.CtrlCHandler;
     Console.WriteLine("Dashboard started");
 }
Exemplo n.º 5
0
        public DistanceServiceThing(string thingPropertiesURI, float latitude, float longitude)
        {
            DataRiver = DataRiver.GetInstance();
            Thing     = CreateThing(DataRiver, thingPropertiesURI);

            WarehouseLat            = latitude;
            WarehouseLng            = longitude;
            Stop                    = false;
            Console.CancelKeyPress += this.CtrlCHandler;
            Console.WriteLine("Distance Service started");
        }
Exemplo n.º 6
0
        public GPSSensor(string thingPropertiesURI, float latitude, float longitude)
        {
            DataRiver = DataRiver.GetInstance();
            Thing     = CreateThing(DataRiver, thingPropertiesURI);

            TruckLat = latitude;
            TruckLng = longitude;
            Stop     = false;
            Console.CancelKeyPress += this.CtrlCHandler;
            Console.WriteLine("GPS Sensor started");
        }
Exemplo n.º 7
0
        public GatewayService(string thingPropertiesURI, int windowHeight)
        {
            DataRiver           = DataRiver.GetInstance();
            Thing               = CreateThing(DataRiver, thingPropertiesURI);
            Stop                = false;
            WindowHeightInLines = windowHeight;

            var comparer = new DataFlowKeyComparer();

            SampleCount             = new Dictionary <DataFlowKey, DataFlowValue>(comparer);
            Console.CancelKeyPress += this.CtrlCHandler;
            Console.WriteLine("Gateway Service started");
        }
Exemplo n.º 8
0
        public Camera(string thingPropertiesURI)
        {
            DataRiver      = DataRiver.GetInstance();
            Thing          = CreateThing(DataRiver, thingPropertiesURI);
            RelatedCameras = new Dictionary <string, string>();
            Threads        = new List <Thread>();

            Stop = false;
            Console.CancelKeyPress += this.CtrlCHandler;
            Console.WriteLine("Camera started");

            SetState("on");
        }
Exemplo n.º 9
0
        public ThingBrowser(string thingPropertiesURI)
        {
            DataRiver = DataRiver.GetInstance();

            // Add listener for discovery of Things
            CustomDispatcher = new Dispatcher();
            NewThingListener = new NewThingDiscoveredListener(DataRiver);
            DataRiver.AddListener(NewThingListener, CustomDispatcher);

            Thing = CreateThing(DataRiver, thingPropertiesURI);
            Stop  = false;

            Console.CancelKeyPress += this.CtrlCHandler;
            Console.WriteLine("ThingBrowser started");
        }
Exemplo n.º 10
0
        public void Dispose()
        {
            // Remove the discovered Thing listener that was added during class initialization
            try
            {
                DataRiver.RemoveListener(NewThingListener, CustomDispatcher);
            }
            catch (ThingAPIException e)
            {
                Console.WriteLine($"Unexpected error while removing discovered Thing listener: {e.Message}");
            }

            DataRiver.Close();
            DataRiver.Dispose();
            Console.WriteLine("ThingBrowser stopped");
        }
Exemplo n.º 11
0
        public void Dispose()
        {
            try
            {
                // Set camera state to 'off'
                SetState("off");
            }
            catch (ThingAPIException e)
            {
                Console.WriteLine($"Error setting camera state to off: {e.Message}");
            }

            // Stop and join threads
            Closed = true;
            foreach (Thread myThread in Threads)
            {
                myThread.Join();
            }

            DataRiver.Close();
            DataRiver.Dispose();
            Console.WriteLine("Camera stopped");
        }
Exemplo n.º 12
0
 public void Dispose()
 {
     DataRiver.Close();
     DataRiver.Dispose();
     Console.WriteLine("Dashboard stopped");
 }
Exemplo n.º 13
0
 public void Dispose()
 {
     DataRiver.Close();
     DataRiver.Dispose();
     Console.WriteLine("GPS Sensor stopped");
 }
Exemplo n.º 14
0
 public void Dispose()
 {
     DataRiver.Close();
     DataRiver.Dispose();
     Console.WriteLine("Temperature Sensor stopped");
 }
Exemplo n.º 15
0
 public void Dispose()
 {
     DataRiver.Close();
     DataRiver.Dispose();
     Console.WriteLine("# Ping stopped");
 }
Exemplo n.º 16
0
 public void Dispose()
 {
     DataRiver.Close();
     DataRiver.Dispose();
     Console.WriteLine("Throughput reader stopped");
 }
Exemplo n.º 17
0
 public void Dispose()
 {
     DataRiver.Close();
     DataRiver.Dispose();
     Console.WriteLine("Gateway Service stopped");
 }
 public void Dispose()
 {
     DataRiver.Close();
     DataRiver.Dispose();
     Console.WriteLine("Rotational Speed Sensor stopped");
 }
Exemplo n.º 19
0
        public int Run(ulong runningTime, string barcodeFilePath)
        {
            StartTimestamp = DateTime.Now;

            int      barcodeIndex     = 0;
            DateTime barcodeTimestamp = StartTimestamp.AddMilliseconds(-BarcodeIntervalMS);

            // Get barcodes
            List <string> barcodes = ReadBarCodes(barcodeFilePath);

            if (barcodes.Count == 0)
            {
                Console.WriteLine("Error: no barcodes found");
                return(1);
            }

            // Add listener for new Things
            var cameraDiscoveredListener = new CameraThingDiscoveredListener(this);

            DataRiver.AddListener(cameraDiscoveredListener);

            // Add listener for lost Things
            var cameraLostListener = new CameraThingLostListener(this);

            DataRiver.AddListener(cameraLostListener);

            // Check for related camera already in the discovered things registry
            System.Threading.Thread.Sleep(CameraInitialDelayMS);
            CheckRegistryForRelatedCameras();

            do
            {
                var now = DateTime.Now;

                // Check if next barcode should be read
                if (barcodeIndex < barcodes.Count &&
                    ((now.Subtract(barcodeTimestamp).TotalSeconds * 1000) > BarcodeIntervalMS))
                {
                    string barcode = barcodes[barcodeIndex];
                    barcodeIndex++;

                    // Randomly skip some of the barcodes
                    if (StaticRandom.Rand(0, 100) > BarcodeSkipPercentage)
                    {
                        ParameterizedThreadStart pts = new ParameterizedThreadStart(BarcodeTask);
                        Thread t = new Thread(pts);
                        Threads.Add(t);
                        t.Start(barcode);
                    }

                    // Update timestamp
                    barcodeTimestamp = now;
                }

                // Sleep for some time
                System.Threading.Thread.Sleep(CameraDelayMS);
            } while (!Stop && SecondsExecuting(StartTimestamp) < runningTime);

            // Remove listeners
            DataRiver.RemoveListener(cameraLostListener);
            DataRiver.RemoveListener(cameraDiscoveredListener);

            return(0);
        }
Exemplo n.º 20
0
 public NewThingDiscoveredListener(DataRiver dr)
 {
     MyDataRiver = dr;
 }