public void SlabWriterTest()
        {
            var slabWriter = new NHibernateSlabInfoWriter();
            slabWriter.Initialize();

            var dimentionWriter = new NHibernateDimentionValueWriter();
            var realSlabWriter = new RealSlabWriter {
                Writer = slabWriter
            };
            dimentionWriter.Initialize();

            var rnd = new Random();
            var dimentions = new IDimentionValue[] {
                new DimentionValueImpl(rnd.Next(), rnd.Next()),
                new DimentionValueImpl(rnd.Next(), rnd.Next()),
            };

            dimentionWriter.WriteDimentionValues(realSlabWriter.GetNewSlabId(), dimentions);

            var fromDb = dimentionWriter
                .ReadDimentionValue
                (dimentions[1].GetDimentionId(), realSlabWriter.LastSlabId);

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(fromDb.GetValue(), dimentions[1].GetValue());
        }
예제 #2
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("Инициализация завершена.");
        }