Exemplo n.º 1
0
        public void StartSimulationTest()
        {
            ISystemContext                 _context       = new SystemContextFixture();
            TraceSourceFixture             _log           = new TraceSourceFixture();
            List <Tuple <string, object> > _callBackCount = new List <Tuple <string, object> >();
            Range _startRange       = null;
            int   _valueChangeCount = 0;

            using (BoilerState _boilerState = new BoilerState(null, "browseName"))
            {
                _boilerState.RegisterVariable(new List <BaseInstanceState>(), (x, y) => { _callBackCount.Add(Tuple.Create <string, object>(String.Join("_", y), ((BaseVariableState)x).Value)); x.OnStateChanged += (q, w, e) => _valueChangeCount++; });
                Range _level = _boilerState.Drum.LevelIndicator.Output.EURange.Value;
                _startRange = ModelExtensions.CreateRange(_level.High, _level.Low);
                double _startSetPoint = _boilerState.LevelController.SetPoint.Value;
                _boilerState.Logger = _log;
                _boilerState.ClearChangeMasks(_context, true);
                _boilerState.StartSimulation();
                _boilerState.OnStateChanged += (x, y, z) => Assert.Fail();
                System.Threading.Thread.Sleep(10000);
                Assert.AreEqual <int>(20, _callBackCount.Count);
                _boilerState.ClearChangeMasks(_context, true);
                Assert.AreEqual <Range>(_level, _boilerState.Drum.LevelIndicator.Output.EURange.Value);
                Assert.AreEqual <double>(_startSetPoint, _boilerState.LevelController.SetPoint.Value);
            }
            Assert.IsTrue(_log.TraceLog.Count > 10);
            Assert.IsTrue(_log.ErrorTraceLog.Count == 0);
            Assert.AreEqual <int>(20, _callBackCount.Count);
            Assert.IsTrue(600 < _valueChangeCount, $"_valueChangeCount = {_valueChangeCount}");
        }
 private void CreateConfiguration(TraceSourceFixture _log, ushort writerId, string _associationName, string symbolicName, string _inFileName)
 {
     using (BoilerType.BoilerState _boilerState = new BoilerType.BoilerState(null, _associationName))
     {
         _boilerState.Logger = _log;
         SemanticDataSetSource _dataSource           = new SemanticDataSetSource(_boilerState);
         XmlQualifiedName      _type                 = new XmlQualifiedName(BoilerType.BrowseNames.BoilerType, BoilerType.Namespaces.BoilerType);
         XmlQualifiedName      _instanceSymbolicName = new XmlQualifiedName(symbolicName, BoilersSet.Namespaces.BoilersSet);
         _dataSource.CreateConfiguration(_type, _associationName, _instanceSymbolicName, _inFileName, Tuple.Create("UDP", writerId, ProducerId), _log);
     }
 }
        public void CreateConfigurationTest()
        {
            TraceSourceFixture _log        = new TraceSourceFixture();
            string             _inFileName = $@"Deploy\Producer.tml.xml";
            FileInfo           _inFile     = new FileInfo(_inFileName);

            Assert.IsTrue(_inFile.Exists, $"File not exist {_inFile.FullName}");
            CreateConfiguration(_log, 1, "BoilersArea_Boiler #1", "BoilersArea_BoilerAlpha", _inFileName);
            CreateConfiguration(_log, 2, "BoilersArea_Boiler #2", "BoilersArea_BoilerBravo", _inFileName);
            CreateConfiguration(_log, 3, "BoilersArea_Boiler #3", "BoilersArea_BoilerBravo", _inFileName);
            CreateConfiguration(_log, 4, "BoilersArea_Boiler #4", "BoilersArea_BoilerBravo", _inFileName);
            //Assert.Fail($"{Environment.CurrentDirectory}");
        }
        public void ReplaceDataSetFieldsTest()
        {
            TraceSourceFixture _log = new TraceSourceFixture();

            using (BoilerType.BoilerState _boilerState = new BoilerType.BoilerState(null, "browseName"))
            {
                const string _inFileName = @"CommonServiceLocatorInstrumentation\ConfigurationDataProducer.xml";
                FileInfo     _inFile     = new FileInfo(_inFileName);
                Assert.IsTrue(_inFile.Exists, $"File not exist {_inFile.FullName}");
                string _outFileName = @"CommonServiceLocatorInstrumentation\new.ConfigurationDataProducer.xml";
                _boilerState.Logger = _log;
                ISemanticDataSetSource _dataSource = new SemanticDataSetSource(_boilerState);
                ReplaceDataSetFields(_dataSource, "Simple", _inFileName, _outFileName);
            }
        }
        private void ReplaceDataSetFields(ISemanticDataSetSource dataSource, string associationName, string inFileName, string outFileName)
        {
            ITraceSource         _traceSource = new TraceSourceFixture();
            List <FieldMetaData> _lf          = new List <FieldMetaData>();

            foreach (KeyValuePair <string, IVariable> _item in dataSource)
            {
                if (_item.Value.ValueType.BuiltInType == BuiltInType.Null)
                {
                    continue;
                }
                FieldMetaData _field = new FieldMetaData()
                {
                    ProcessValueName = _item.Key,
                    SymbolicName     = _item.Key,
                    TypeInformation  = _item.Value.ValueType
                };
                _lf.Add(_field);
            }
            ConfigurationManagement.ReplaceDataSetFields(_lf.ToArray(), associationName, inFileName, outFileName, _traceSource);
        }
Exemplo n.º 6
0
        public void RegisterVariableTest()
        {
            TraceSourceFixture _log = new TraceSourceFixture();

            using (BoilerState _boilerState = new BoilerState(null, "browseName"))
            {
                _boilerState.Logger = _log;
                Dictionary <string, BaseInstanceState> _vars = new Dictionary <string, BaseInstanceState>();
                _boilerState.RegisterVariable(new List <BaseInstanceState>(), (x, y) => _vars.Add(String.Join("_", y), x));
                foreach (KeyValuePair <string, BaseInstanceState> _item in _vars)
                {
                    BaseVariableState _var = _item.Value as BaseVariableState;
                    Assert.IsNotNull(_var);
                    string _type = _var.Value == null ? "not set" : _var.Value.GetType().Name;
                    Debug.WriteLine($"{_item} {_type}");
                }
                Assert.AreEqual <int>(20, _vars.Count);
            }
            Assert.IsTrue(_log.TraceLog.Count == 0);
            Assert.IsTrue(_log.ErrorTraceLog.Count == 0);
        }