Exemple #1
0
        public static string GetProgramNameCaption(SensorEntity sensor, string programName)
        {
            int idParent = 0;

            if (Convert.ToInt32(sensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Sterilizer)))
            {
                // 灭菌
                idParent = 13;
            }
            else if (Convert.ToInt32(sensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Washer)))
            {
                // 清洗
                idParent = 14;
            }
            else
            {
                return(string.Empty);
            }

            SensorHelper <object> helper = new SensorHelper <object>();
            AssistDataEntity      entity = helper.SelectSingle <AssistDataEntity>("FParentID = " + idParent.ToString() + " and fkey = '" + programName + "'", string.Empty);

            if (entity == null)
            {
                return(programName);
            }
            else
            {
                return(entity.FCaption);
            }
        }
Exemple #2
0
        public async Task <IActionResult> PutSensorEntity([FromRoute] int id, [FromBody] SensorEntity sensorEntity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sensorEntity.Id)
            {
                return(BadRequest());
            }

            _context.Entry(sensorEntity).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SensorEntityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
        public ProbeModel GetProbeData(SensorEntity <TKey> sensorEntity)
        {
            try
            {
                var url            = sensorEntity.SensorApiAddress;
                var client         = new WebClient();
                var responseString = client.DownloadString(url);

                var response = JsonConvert.DeserializeObject <SuplaResponseModel>(responseString);
                if (response.Connected)
                {
                    var probe = new ProbeModel
                    {
                        ProbeDate          = DateTime.Now,
                        TemperatureCelcius = response.Temperature,
                        HumidityPercent    = response.Humidity
                    };
                    return(probe);
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error during load data.");
            }
            return(null);
        }
Exemple #4
0
        public ChartDTO GetChartData(string sdhID)
        {
            //mSyncLast = null;

            IsNew = true;

            mShowPropertyDic = GetShowPropertyData();

            // 刷新状态
            SensorHelper <object> helper = new SensorHelper <object>();

            mSensor = helper.SelectSingle <SensorEntity>(string.Format("SensorID = '{0}'", mSensor.SensorID.ToString().ToUpper()), string.Empty);

            SensorDataHeadBll    bllHead = new SensorDataHeadBll();
            SensorDataHeadEntity eHead   = bllHead.GetEntity(new Guid(sdhID));

            if (eHead == null)
            {
                return(null);
            }
            else
            {
                if (eHead.IsCompressed != null && eHead.IsCompressed.HasValue && eHead.IsCompressed.Value)
                {
                    // 已压缩
                    mIsCompressed         = true;
                    mSensorCompressedData = new SensorCompressedDataHelper(eHead);
                }

                return(GetChartDataByHead(eHead));
            }
        }
        private SensorEntity Convert(SensorInfo info)
        {
            SensorEntity result = new SensorEntity();

            result.Description = info.Description;
            result.Path        = info.Path;
            result.ProductName = info.ProductName;
            result.SensorName  = info.SensorName;
            return(result);
        }
 public MonitorProcessService(SensorEntity <TKey> sensorEntity, IProbeMonitorService <TKey> probeMonitorService)
 {
     timer = new Timer
     {
         Interval = 1000
     };
     timer.Elapsed           += Timer_Elapsed;
     this.sensorEntity        = sensorEntity;
     this.probeMonitorService = probeMonitorService;
 }
Exemple #7
0
        public async Task <IActionResult> PostSensorEntity([FromBody] SensorEntity sensorEntity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Sensors.Add(sensorEntity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSensorEntity", new { id = sensorEntity.Id }, sensorEntity));
        }
Exemple #8
0
        public SensorInfo(SensorEntity entity)
        {
            if (entity == null)
            {
                return;
            }

            ProductName = entity.ProductName;
            Path        = entity.Path;
            SensorName  = entity.SensorName;
            Description = entity.Description;
        }
Exemple #9
0
        public ChartDTO GetChartDataInc(DateTime?lastReceivedDate, bool canChangeHead)
        {
            //mSyncLast = null;

            IsNew = false;

            // 刷新状态
            SensorHelper <object> helper = new SensorHelper <object>();

            mSensor = helper.SelectSingle <SensorEntity>(string.Format("SensorID = '{0}'", mSensor.SensorID.ToString().ToUpper()), string.Empty);

            SensorDataHeadBll bllHead = new SensorDataHeadBll();

            SensorDataHeadEntity eHead = bllHead.GetNewestSensorDataHeadBySensorID(Sensor.SensorID.ToString().ToUpper());

            if (eHead == null)
            {
                return(null);
            }
            else
            {
                if (eHead.IsCompressed != null && eHead.IsCompressed.HasValue && eHead.IsCompressed.Value)
                {
                    ChartDTO chartData = new ChartDTO();
                    chartData.IsAxisXCustomLabels = false;
                    chartData.ChartTitle          = GetChartTitle();
                    chartData.IsReset             = true;
                    return(chartData);
                }

                if (mHeadEntity != null && eHead.SensorDataHeadID == mHeadEntity.SensorDataHeadID && lastReceivedDate != null && lastReceivedDate.HasValue)
                {
                    return(GetChartDataInc(eHead, lastReceivedDate.Value));
                }
                else
                {
                    if (canChangeHead)
                    {
                        mSensorData = null;
                        ChartDTO dtoChart = GetChartDataByHead(eHead);
                        dtoChart.IsReset = true;
                        IsNew            = true;
                        return(dtoChart);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Exemple #10
0
        private static ProbeEntity <TKey> GetEntityModel(ProbeModel data, SensorEntity <TKey> sensorEntity)
        {
            var probe = new ProbeEntity <TKey>
            {
                SensorId           = sensorEntity.Id,
                ProbeDate          = DateTime.Now,
                TemperatureCelcius = data.TemperatureCelcius,
                Pm1             = data.Pm1,
                Pm2_5           = data.Pm2_5,
                Pm10            = data.Pm10,
                HumidityPercent = data.HumidityPercent
            };

            return(probe);
        }
 public void AddSensor(SensorEntity info)
 {
     try
     {
         string key   = GetSensorInfoKey(info.ProductName, info.Path);
         string value = JsonSerializer.Serialize(info);
         lock (_accessLock)
         {
             _database.Put(key, value);
         }
     }
     catch (Exception e)
     {
         _logger.Error(e, $"Failed to add sensor info for {info.Path}");
     }
 }
Exemple #12
0
        public List <SensorEntity> GetProductSensors(string productName)
        {
            List <SensorEntity> sensors     = new List <SensorEntity>();
            List <string>       sensorPaths = _environmentDatabase.GetSensorsList(productName);

            foreach (var path in sensorPaths)
            {
                SensorEntity sensorEntity = _environmentDatabase.GetSensorInfo(productName, path);
                if (sensorEntity != null)
                {
                    sensors.Add(sensorEntity);
                }
            }

            return(sensors);
        }
        public void AddSensor(SensorEntity info)
        {
            var key = PrefixConstants.GetSensorInfoKey(info.ProductName, info.Path);

            byte[] bytesKey    = Encoding.UTF8.GetBytes(key);
            string stringValue = JsonSerializer.Serialize(info);

            byte[] bytesValue = Encoding.UTF8.GetBytes(stringValue);
            try
            {
                _database.Put(bytesKey, bytesValue);
            }
            catch (Exception e)
            {
                _logger.Error(e, $"Failed to put sensor info for {info.ProductName}/{info.Path}");
            }
        }
Exemple #14
0
        public async Task RecieveSensorDataAsync(SensorEntity <TKey> sensorEntity)
        {
            var client     = GetClient(sensorEntity.Client);
            var latestData = await probeService.GetLatestDataAsync(sensorEntity.Id);

            var data = client.GetProbeData(sensorEntity);

            if (data == null)
            {
                return;
            }


            if (IsModelChanged(latestData, data))
            {
                var entityModel = GetEntityModel(data, sensorEntity);
                await probeService.AddAsync(entityModel);
            }
        }
Exemple #15
0
        public SensorStatusDTO GetStatusData()
        {
            // 刷新状态
            SensorHelper <object> helper = new SensorHelper <object>();

            mSensor = helper.SelectSingle <SensorEntity>(string.Format("SensorID = '{0}'", mSensor.SensorID.ToString().ToUpper()), string.Empty);

            SensorDataHeadBll    bllHead = new SensorDataHeadBll();
            SensorDataHeadEntity eHead   = bllHead.GetNewestSensorDataHeadBySensorID(Sensor.SensorID.ToString().ToUpper());

            if (eHead == null)
            {
                SensorStatusDTO dtoStatus = new SensorStatusDTO();
                dtoStatus.SensorCaption = mSensor.SensorName;
                dtoStatus.SensorStatus  = mSensor.PositionMark;
                return(dtoStatus);
            }

            if (eHead.IsCompressed != null && eHead.IsCompressed.HasValue && eHead.IsCompressed.Value)
            {
                SensorStatusDTO dtoStatus = new SensorStatusDTO();
                dtoStatus.SensorCaption = mSensor.SensorName;
                dtoStatus.SensorStatus  = mSensor.PositionMark;
                return(dtoStatus);
            }

            if (Convert.ToInt32(Sensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Sterilizer)))
            {
                // 灭菌
                return(GetStatusData(eHead));
            }
            else if (Convert.ToInt32(Sensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Washer)))
            {
                // 清洗
                return(GetStatusData(eHead));
            }
            else
            {
                logger.WarnFormat("未处理的设备类型([传感器:{0},设备类型:{1}])", Sensor.SensorKey, Sensor.SensorType);

                return(null);
            }
        }
 void BtnGlucometro_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (iniciar() && !string.IsNullOrEmpty(LblGlucometro.Text))
         {
             puerto.Write(@"g");
             SensorEntity sens = lstSensor.Find(x => x.NombreSensor.IndexOf(BtnGlucometro.Content.ToString(), StringComparison.OrdinalIgnoreCase) != -1);
             if (sens != null)
             {
                 idSensorActivo = sens.IdSensor;
             }
             ActivarBotones(false);
         }
     }
     catch (Exception ex)
     {
         TxtMensaje.Text = ex.Message;
     }
 }
Exemple #17
0
        public ChartDTO GetChartData()
        {
            mSyncLast = null;
            mDataDic  = new Dictionary <string, DataRow[]>();

            IsNew = true;

            mProgramData = null;

            mShowPropertyDic = GetShowPropertyData();

            // 刷新状态
            SensorHelper <object> helper = new SensorHelper <object>();

            mSensor = helper.SelectSingle <SensorEntity>(string.Format("SensorID = '{0}'", mSensor.SensorID.ToString().ToUpper()), string.Empty);

            SensorDataHeadBll    bllHead = new SensorDataHeadBll();
            SensorDataHeadEntity eHead   = bllHead.GetNewestSensorDataHeadBySensorID(Sensor.SensorID.ToString().ToUpper());

            if (eHead == null)
            {
                ChartDTO chartData = new ChartDTO();
                chartData.ChartTitle = GetChartTitle();
                return(chartData);
            }
            else
            {
                if (eHead.IsCompressed != null && eHead.IsCompressed.HasValue && eHead.IsCompressed.Value)
                {
                    ChartDTO chartData = new ChartDTO();
                    chartData.ChartTitle = GetChartTitle();
                    return(chartData);
                }

                //SensorDataLineBll bllLine = new SensorDataLineBll();
                //mSectionList = bllLine.GetSensorDataLineByDataType(eHead.SensorDataHeadID.ToString(), Utility.GetEnumValue(DataType.Body_SectionTitle));
                mProgramData = GetProgramData(eHead);

                return(GetChartDataByHead(eHead));
            }
        }
        public void NextPaciente()
        {
            foreach (SensorEntity item in lstSensor)
            {
                foreach (Paciente paci in lstPaciente)
                {
                    SensorEntity senPaci = paci.LstSensor.Find(x => x.NombreSensor.IndexOf(item.NombreSensor, StringComparison.OrdinalIgnoreCase) != -1);
                    if (senPaci == null)
                    {
                        continue;
                    }
                    if (paci.StatusPaciente == StatusPaciente.Disponible && item.StatusSensor == StatusSensor.Disponible && (senPaci.LstResultado == null || senPaci.LstResultado.Count <= 0))
                    {
                        paci.StatusPaciente = StatusPaciente.Asignado;
                        item.StatusSensor   = StatusSensor.Ocupado;
                        switch (item.IdSensor)
                        {
                        case (int)SensorType.Electrocardiograma:
                            LblElectro.Text = paci.Nombre;
                            break;

                        case (int)SensorType.Glucometro:
                            LblGlucometro.Text = paci.Nombre;
                            break;

                        case (int)SensorType.Pulsiometro:
                            LblPulsiometro.Text = paci.Nombre;
                            break;

                        case (int)SensorType.Medida:
                            LblMedida.Text = paci.Nombre;
                            break;

                        case (int)SensorType.Peso:
                            LblPeso.Text = paci.Nombre;
                            break;
                        }
                    }
                }
            }
        }
        public SensorEntity GetSensorInfo(string productName, string path)
        {
            SensorEntity sensorInfo = default(SensorEntity);

            try
            {
                string key = GetSensorInfoKey(productName, path);
                string value;
                lock (_accessLock)
                {
                    value = _database.Get(key);
                }

                sensorInfo = JsonSerializer.Deserialize <SensorEntity>(value);
            }
            catch (Exception e)
            {
                _logger.Error(e, $"Failed to read SensorEntity for {productName}:{path}");
            }

            return(sensorInfo);
        }
        public SensorInfo(SensorEntity entity)
        {
            if (entity == null)
            {
                return;
            }

            ProductName = entity.ProductName;
            Path        = entity.Path;
            SensorName  = entity.SensorName;
            Description = entity.Description;
            SensorType  = (SensorType)entity.SensorType;
            //ExpectedUpdateInterval = entity.ExpectedUpdateInterval;
            ExpectedUpdateInterval = new TimeSpan(entity.ExpectedUpdateIntervalTicks);
            Unit = entity.Unit;
            ValidationParameters = new List <SensorValidationParameter>();
            if (entity.ValidationParameters != null && entity.ValidationParameters.Any())
            {
                entity.ValidationParameters.ForEach(
                    p => ValidationParameters.Add(new SensorValidationParameter(p)));
            }
        }
        public ProbeModel GetProbeData(SensorEntity <TKey> sensorEntity)
        {
            try
            {
                var url            = sensorEntity.SensorApiAddress;
                var client         = new WebClient();
                var responseString = client.DownloadString(url);

                switch (sensorEntity.Type)
                {
                case SensorType.Temperature:
                    return(GetTemperature(responseString));

                case SensorType.AirQuality:
                    return(GetAirData(responseString));
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error occured during recieving probe data.");
            }
            return(null);
        }
Exemple #22
0
        public ChartDTO GetChartData()
        {
            //mSyncLast = null;

            IsNew = true;

            mShowPropertyDic = GetShowPropertyData();

            // 刷新状态
            SensorHelper <object> helper = new SensorHelper <object>();

            mSensor = helper.SelectSingle <SensorEntity>(string.Format("SensorID = '{0}'", mSensor.SensorID.ToString().ToUpper()), string.Empty);

            SensorDataHeadBll    bllHead = new SensorDataHeadBll();
            SensorDataHeadEntity eHead   = bllHead.GetNewestSensorDataHeadBySensorID(Sensor.SensorID.ToString().ToUpper());

            if (eHead == null)
            {
                ChartDTO chartData = new ChartDTO();
                chartData.IsAxisXCustomLabels = false;
                chartData.ChartTitle          = GetChartTitle();
                return(chartData);
            }
            else
            {
                if (eHead.IsCompressed != null && eHead.IsCompressed.HasValue && eHead.IsCompressed.Value)
                {
                    ChartDTO chartData = new ChartDTO();
                    chartData.IsAxisXCustomLabels = false;
                    chartData.ChartTitle          = GetChartTitle();
                    return(chartData);
                }

                return(GetChartDataByHead(eHead));
            }
        }
Exemple #23
0
 public static IObservable <StateChange <SensorEntity, EntityState <SensorAttributes> > > StateAllChangesWithCurrent(this SensorEntity entity)
 {
     return(entity.StateAllChangesWithCurrent <SensorEntity, EntityState <SensorAttributes>, SensorAttributes>());
 }
 //To update object simply rewrite it
 public void UpdateSensor(SensorEntity sensorEntity)
 {
     _databaseWorker.AddSensor(sensorEntity);
 }
 public void AddSensor(SensorEntity sensorEntity)
 {
     _databaseWorker.AddNewSensorToList(sensorEntity.ProductName, sensorEntity.Path);
     _databaseWorker.AddSensor(sensorEntity);
 }
 public void RemoveSensor(SensorEntity sensorEntity)
 {
     RemoveSensor(sensorEntity.ProductName, sensorEntity.Path);
 }
        private void AnalyseData(IList <string> row, string strByteData)
        {
            string   sysNo     = ParseHelper.ParseString(row[(int)SystemData.SystemNo]);
            string   batchNo   = ParseHelper.ParseString(row[(int)SystemData.BatchNo]);
            DateTime timestamp = ConvertDate(row[(int)SystemData.Timestamp]);

            SensorHelper <object> helperSensor = new SensorHelper <object>();
            SensorEntity          eSensor      = helperSensor.SelectSingle <SensorEntity>(string.Format("SensorGroup = '{0}' AND SensorKey = '{1}'", mSensorGroup, sysNo), string.Empty);

            if (eSensor == null)
            {
                logger.WarnFormat("系统中组和编号为:[{0}].[{1}]的设备没有登记。", mSensorGroup, sysNo);
                return;
            }

            SensorDataHeadEntity eHead = helperSensor.SelectSingle <SensorDataHeadEntity>(string.Format("SensorID = '{0}' AND DataKey = '{1}'", eSensor.SensorID.ToString().ToUpper(), batchNo), string.Empty);

            Enumerator.BelimedStatus status;//0-Off,1-On,2-Run,3-End
            try
            {
                status = (Enumerator.BelimedStatus)Enum.Parse(typeof(Enumerator.BelimedStatus), row[(int)SystemData.Status]);
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("传感器状态取得失败,状态值:[{0}]", row[(int)SystemData.Status]);
                throw ex;
            }

            System.Threading.Monitor.Enter(Monitor.Common.Utility.SyncSqlLock);
            try
            {
                logger.Info("开始保存数据。");
                using (TransactionScope tran = Monitor.Common.Utility.GetTransactionScope())
                {
                    switch (status)
                    {
                    case Enumerator.BelimedStatus.Off:
                        eSensor.PositionMark = status.ToString();
                        helperSensor.Update(eSensor);
                        break;

                    case Enumerator.BelimedStatus.On:
                        eSensor.PositionMark = status.ToString();
                        helperSensor.Update(eSensor);
                        break;

                    case Enumerator.BelimedStatus.Run:
                        if (eHead == null)
                        {
                            // 主数据
                            eHead = new SensorDataHeadEntity();
                            eHead.SensorDataHeadID = Guid.NewGuid();
                            eHead.SensorID         = eSensor.SensorID;
                            eHead.DataKey          = batchNo;
                            eHead.BeginDate        = timestamp;
                            eHead.IsCompressed     = false;
                            eHead.DataVer          = DataVersion.V1.ToString();

                            helperSensor.Create(eHead);
                        }

                        eSensor.PositionMark = status.ToString();
                        helperSensor.Update(eSensor);

                        // 原始数据
                        SensorDataRawLineEntity eRawLine = new SensorDataRawLineEntity();
                        eRawLine.SensorDataRawLineID = Guid.NewGuid();
                        eRawLine.SensorDataHeadID    = eHead.SensorDataHeadID;
                        eRawLine.ReceivedDate        = DateTime.Now;
                        eRawLine.RawData             = strByteData;
                        helperSensor.Create(eRawLine);

                        // 解析数据
                        SensorDataLineEntity eLine = new SensorDataLineEntity();
                        eLine.SensorDataLineID    = Guid.NewGuid();
                        eLine.SensorDataHeadID    = eHead.SensorDataHeadID;
                        eLine.SensorDataRawLineID = eRawLine.SensorDataRawLineID;
                        eLine.ReceivedDate        = eRawLine.ReceivedDate;
                        eLine.SensorDate          = timestamp;
                        if (eLine.SensorDate != null && eLine.SensorDate.HasValue && eHead.BeginDate != null && eHead.BeginDate.HasValue)
                        {
                            eLine.SensorTimeSpan = Convert.ToInt64(eLine.SensorDate.Value.Subtract(eHead.BeginDate.Value).TotalMilliseconds);
                        }
                        //eLine.AnalysedData = row.ToString();
                        eLine.AnalysedData = string.Join(";", row.ToArray <string>());
                        helperSensor.Create(eLine);

                        SensorDataLineValueEntity eLineValue = null;
                        for (int i = 0; i < row.Count; i++)
                        {
                            eLineValue = new SensorDataLineValueEntity();
                            eLineValue.SensorDataLineValueID = Guid.NewGuid();
                            eLineValue.SensorDataHeadID      = eLine.SensorDataHeadID;
                            eLineValue.SensorDataLineID      = eLine.SensorDataLineID;

                            switch (i)
                            {
                            case (int)SystemData.Status:
                                string ss = ParseHelper.ParseString(row[i]);
                                if (!string.IsNullOrEmpty(ss))
                                {
                                    eLineValue.ValueType     = SystemData.Status.ToString();
                                    eLineValue.ContentString = ss;
                                    helperSensor.Create(eLineValue);
                                }
                                break;

                            case (int)SystemData.ErrorNo:
                                string errorNo = ParseHelper.ParseString(row[i]);
                                if (!string.IsNullOrEmpty(errorNo))
                                {
                                    eLineValue.ValueType     = SystemData.ErrorNo.ToString();
                                    eLineValue.ContentString = errorNo;
                                    helperSensor.Create(eLineValue);
                                }
                                break;

                            case (int)SystemData.ProgramNo:
                                eLineValue.ValueType     = SystemData.ProgramNo.ToString();
                                eLineValue.ContentString = ParseHelper.ParseString(row[i]);
                                helperSensor.Create(eLineValue);
                                break;

                            case (int)SystemData.ProgramName:
                                eLineValue.ValueType     = SystemData.ProgramName.ToString();
                                eLineValue.ContentString = ParseHelper.ParseString(row[i]);
                                helperSensor.Create(eLineValue);
                                break;

                            case (int)SystemData.ProgramPhase:
                                eLineValue.ValueType     = SystemData.ProgramPhase.ToString();
                                eLineValue.ContentString = ParseHelper.ParseString(row[i]);
                                helperSensor.Create(eLineValue);
                                break;

                            default:
                                break;
                            }

                            if (Convert.ToInt32(eSensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Washer)))
                            {
                                switch (i)
                                {
                                case (int)SystemData.MeasurementSensor1:
                                    // Med
                                    eLineValue.ValueType     = SystemData.MeasurementSensor1.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]);
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor2:
                                    // CT
                                    eLineValue.ValueType     = SystemData.MeasurementSensor2.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]) / 10;
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor3:
                                    // CDNo
                                    eLineValue.ValueType     = SystemData.MeasurementSensor3.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]);
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor4:
                                    // DosV
                                    eLineValue.ValueType     = SystemData.MeasurementSensor4.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]) / 10;
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor5:
                                    // Ao
                                    eLineValue.ValueType     = SystemData.MeasurementSensor5.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]);
                                    helperSensor.Create(eLineValue);
                                    break;

                                default:
                                    break;
                                }
                            }
                            else if (Convert.ToInt32(eSensor.SensorType).Equals(Convert.ToInt32(Common.Consts.SensorType.Sterilizer)))
                            {
                                switch (i)
                                {
                                case (int)SystemData.MeasurementSensor1:
                                    // T1
                                    eLineValue.ValueType     = SystemData.MeasurementSensor1.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]) / 10;
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor2:
                                    // T2
                                    eLineValue.ValueType     = SystemData.MeasurementSensor2.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]) / 10;
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor4:
                                    // P1
                                    eLineValue.ValueType     = SystemData.MeasurementSensor4.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]);
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor5:
                                    // P2
                                    eLineValue.ValueType     = SystemData.MeasurementSensor5.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]);
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor6:
                                    // P3
                                    eLineValue.ValueType     = SystemData.MeasurementSensor6.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]);
                                    helperSensor.Create(eLineValue);
                                    break;

                                case (int)SystemData.MeasurementSensor7:
                                    // P4
                                    eLineValue.ValueType     = SystemData.MeasurementSensor7.ToString();
                                    eLineValue.ContentNumber = Convert.ToDecimal(row[i]);
                                    helperSensor.Create(eLineValue);
                                    break;

                                default:
                                    break;
                                }
                            }
                        }

                        break;

                    case Enumerator.BelimedStatus.End:
                        if (eHead != null)
                        {
                            eHead.EndDate = ConvertDate(row[(int)SystemData.Timestamp]);
                            helperSensor.Update(eHead);

                            eSensor.PositionMark = status.ToString();
                            eSensor.Remarks      = ParseHelper.ParseString(row[(int)SystemData.StatusInfo]);
                            helperSensor.Update(eSensor);

                            if (eHead.LogID != null && eHead.LogID.HasValue && eHead.LogID.Value != Guid.Empty)
                            {
                                DevicesUseLogEntity logEntity = helperSensor.SelectSingle <DevicesUseLogEntity>("LogID='" + eHead.LogID.Value.ToString().ToUpper() + "'", string.Empty);
                                if (logEntity != null)
                                {
                                    if (eHead.BeginDate != null && eHead.BeginDate.HasValue)
                                    {
                                        logEntity.OldBeginDate = logEntity.BeginDate;
                                        logEntity.BeginDate    = eHead.BeginDate.Value;
                                    }
                                    logEntity.EndDate = eHead.EndDate;
                                    // TODO: DevicesUseLog 关联到 Sensor 的字段
                                    //logEntity.MonitorDataID = eHead.SensorDataHeadID;

                                    helperSensor.Update(logEntity);
                                }
                            }
                        }

                        break;

                    default:
                        break;
                    }
                    tran.Complete();
                    logger.Info("数据保存成功。");
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(Monitor.Common.Utility.SyncSqlLock);
            }
        }
Exemple #28
0
 public void AddSensor(SensorEntity entity)
 {
     _environmentDatabase.AddNewSensorToList(entity.ProductName, entity.Path);
     _environmentDatabase.AddSensor(entity);
 }
 public EntityBase <SensorEntity> Get(SensorEntity id)
 {
     throw new NotImplementedException();
 }
 public void Delete(SensorEntity id)
 {
     throw new NotImplementedException();
 }