public void SensorValueDataWriterSaveData()
        {
            var dataWriter = new NHibernateSensorValueWriter();
            dataWriter.Initialize();

            var rnd = new Random();
            var value = new SensorValueInfoImpl(rnd.Next(), rnd.Next(), rnd.Next());
            dataWriter.WriteSensorValueInfo(value);

            var fromDb = dataWriter.ReadSensorValueEntity(value.GetSensorId(), value.GetTime());

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(value.GetValue(), fromDb.Value);
            Assert.AreEqual(value.GetTime(), fromDb.Time);
            Assert.AreEqual(value.GetSensorId(), fromDb.SensorId);
            Assert.Greater(fromDb.Id, 0);

            dataWriter.Uninitialize();
        }
 public void SensorValueDataWriterInitialize()
 {
     var dataWriter = new NHibernateSensorValueWriter();
     dataWriter.Initialize();
     dataWriter.Uninitialize();
 }
Beispiel #3
0
        protected override void DoInitialize()
        {
            logger.Info("Инициализация...");

            dimentionConfiguration = new NHibernateDimentionConfigurationImpl();
            dataProviderConfiguration = new XmlDataProviderConfigurationImpl("Settings/OpcConfiguration.xml");
            sensorConfiguration = new XmlSensorConfigurationImpl("Settings/SensorConfiguration.xml");

            dataProvider = new OpcDataProviderImpl();
            calibrator = new CalibratorImpl();
            //dataProvider = new EmulatorDataProvider();
            slabBuilder = new SlabBuilderImpl();
            dimentionCalculator = new DimentionCalculatorImpl();
            sensorValueContainer = new SensorValueContainerImpl();
            dimentionValueContainer = new DimentionValueContainerImpl();
            standartSizeReaderWriter = new NHibernateStandartSizeReaderWriter();
            regulationsReaderWriter = new NHibernateRegulationReaderWriter();

            sensorValueReaderWriter = new NHibernateSensorValueWriter();
            dimentionValueWriter = new NHibernateDimentionValueWriter();
            slabWriter = new NHibernateSlabInfoWriter();
            slabReader = slabWriter as ISlabInfoReader;

            sensorValueContainer.SunbscribeContainerListener(this);

            dataProvider.SetSensorConfiguration(sensorConfiguration);
            dataProvider.SetSensorValueContainer(sensorValueContainer);
            dataProvider.SetDataProviderConfiguration(dataProviderConfiguration);
            dataProvider.SubscribeDataProviderListener(this);

            slabBuilder.SetCalibrator(calibrator);
            slabBuilder.SetSensorConfiguration(sensorConfiguration);
            slabBuilder.SetSensorValueContainer(sensorValueContainer);

            dimentionCalculator.SetDimentionConfiguration(dimentionConfiguration);
            dimentionCalculator.SetDimentionValueContainer(dimentionValueContainer);

            // Для построения точек при запросе пользователя.
            userSensorValueContainer = new SensorValueContainerImpl();
            userSlabBuilder = new SlabBuilderImpl();
            userSlabBuilder.SetSensorValueContainer(userSensorValueContainer);
            userSlabBuilder.SetSensorConfiguration(sensorConfiguration);
            userSlabBuilder.SetCalibrator(calibrator);

            dimentionConfiguration.Initialize();
            standartSizeReaderWriter.Initialize();
            regulationsReaderWriter.Initialize();
            dataProviderConfiguration.Initialize();
            sensorConfiguration.Initialize();
            sensorValueReaderWriter.Initialize();
            slabWriter.Initialize();
            dimentionValueWriter.Initialize();
            dimentionCalculator.Initialize();
            calibrator.Initialize();
            slabBuilder.Initialize();
            userSlabBuilder.Initialize();
            dataProvider.Initialize();

            logger.Info("Инициализация завершена.");
        }