Ejemplo n.º 1
0
        private void Client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Received = " + Encoding.UTF8.GetString(e.Message) + " on topic " + e.Topic);
            var bodyObj    = JsonSerializer.Deserialize <DetectionModel>(Encoding.UTF8.GetString(e.Message));
            var topicStr   = e.Topic;
            var splitTopic = topicStr.Split("/");

            var detection = new DetectionConfiguration
            {
                ScooterId           = Convert.ToInt32(splitTopic[1]),
                SensorId            = Convert.ToInt32(splitTopic[2]),
                SensorType          = splitTopic[3],
                SensorValue         = bodyObj.SensorValue,
                SensorDetectionDate = bodyObj.SensorDetectionDate
            };

            try
            {
                _detectionRepoitory.insertData(detection, _connectionString);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Detection inserted");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
 public void UpdateDevice(BcDevices bcDevices)
 {
     if (bcDevices == null)
     {
         throw new ArgumentNullException();
     }
     if (this._device != null && bcDevices.Id != this._device.Id)
     {
         throw new InvalidOperationException("bcDevices.Id != _device.Id");
     }
     if (!this.HasDifferProperties(bcDevices))
     {
         return;
     }
     lock (this._processingWorkers)
     {
         ParallelEnumerable.ForAll <Worker>(ParallelEnumerable.AsParallel <Worker>((IEnumerable <Worker>) this._processingWorkers), (Action <Worker>)(worker => worker.Pause()));
         this._device = bcDevices;
         this._detectionConfiguration = new DetectionConfiguration()
         {
             MinFace            = (uint)this._device.MinFace,
             DetectionThreshold = (double)this._device.DetectorScore
         };
         this.SyncProcessorCount();
         ParallelEnumerable.ForAll <Worker>(ParallelEnumerable.AsParallel <Worker>((IEnumerable <Worker>) this._processingWorkers), (Action <Worker>)(worker => worker.Resume()));
     }
 }
Ejemplo n.º 3
0
 public AllFaceConfigurations()
 {
     storageName           = "";
     detection             = new DetectionConfiguration();
     landmarks             = new LandmarksConfiguration();
     pose                  = new PoseConfiguration();
     expressions           = new ExpressionsPropertiesINT();
     recognitionProperties = new RecognitionConfiguration.RecognitionProperties();
     pulseProperties       = new PulseConfiguration.PulseProperties();
     storageDesc           = new RecognitionConfiguration.RecognitionStorageDesc();
 }
 public ResponseAPI Post([FromBody] DetectionConfiguration configuration)
 {
     try
     {
         _detectionRepository.insertData(configuration, _connectionStringSQL);
         return(new ResponseAPI {
             StatusCode = 200, Message = "Detection inserted"
         });
     }
     catch (Exception e)
     {
         return(new ResponseAPI {
             StatusCode = 500, Message = e.Message
         });
     }
 }
Ejemplo n.º 5
0
 public AllFaceConfigurations()
 {
     storageName = "";
     detection = new DetectionConfiguration();
     landmarks = new LandmarksConfiguration();
     pose = new PoseConfiguration();
     expressions = new ExpressionsPropertiesINT();
     recognitionProperties = new RecognitionConfiguration.RecognitionProperties();
     pulseProperties = new PulseConfiguration.PulseProperties();
     storageDesc = new RecognitionConfiguration.RecognitionStorageDesc();
 }