Ejemplo n.º 1
0
        protected BaseFunctions()
        {
            var factory = new MomErrFactory(ErrSourceCode, MomErrType.Calc);

            factory.AddGoodDescr(0);
            ErrPool = new MomErrPool(factory);

            using (var rec = new AdoReader(ItStatic.InfoTaskDir() + @"General\General.accdb",
                                           "SELECT FunctionsOverloads.*, Functions.Name, Functions.Synonym, Functions.Code, Functions.CalcType FROM Functions INNER JOIN FunctionsOverloads ON Functions.Id = FunctionsOverloads.FunctionId " +
                                           "WHERE " + FunsWhereCondition + " ORDER BY FunctionsOverloads.FunctionId, FunctionsOverloads.RunNumber"))
                while (rec.Read())
                {
                    string name    = rec.GetString("Name");
                    string synonym = rec.GetString("Synonym");
                    if (!synonym.IsEmpty())
                    {
                        name += " (" + synonym + ")";
                    }
                    string code = (rec.GetString("Code") ?? (synonym ?? name)) + "_";
                    for (int i = 1; i <= 9 && rec.GetString("Operand" + i) != null; i++)
                    {
                        code += rec.GetString("Operand" + i).ToDataType().ToLetter();
                    }
                    for (int i = 1; i <= 2 && rec.GetString("More" + i) != null; i++)
                    {
                        code += rec.GetString("More" + i).ToDataType().ToLetter();
                    }
                    var errNum = rec.GetInt("IdOverload") * 10;
                    var ftype  = rec.GetString("CalcType");
                    Funs.Add(code, CreateFun(code, ftype, errNum));
                    factory.AddDescr(errNum, "Недопустимые параметры функции " + name);
                }
        }
Ejemplo n.º 2
0
        //Создание фабрики ошибок
        protected virtual IMomErrFactory MakeErrFactory()
        {
            var factory = new MomErrFactory(ProviderConnect.Code, MomErrType.Source);

            factory.AddGoodDescr(0);
            return(factory);
        }
Ejemplo n.º 3
0
        //Создание фабрики ошибок
        protected override IMomErrFactory MakeErrFactory()
        {
            var factory = new MomErrFactory(ProviderConnect.Code, MomErrType.Source);

            factory.AddGoodDescr(192);
            factory.AddDescr(0, "Bad Quality of undetermined state");
            factory.AddDescr(1, "No data available, tag did not exist at the time");
            factory.AddDescr(2, "Running insert");
            factory.AddDescr(10, "Communication loss");
            factory.AddDescr(16, "Good value, received out of time sync (cyclic tag)");
            factory.AddDescr(17, "Duplicate time stamp; infinite slope");
            factory.AddDescr(20, "IDAS overflow recovery");
            factory.AddDescr(24, "IOServer communication failed");
            factory.AddDescr(33, "Violation of History Duration license feature");
            factory.AddDescr(44, "Pipe reconnect");
            factory.AddDescr(64, "Cannot convert");
            factory.AddDescr(150, "Storage startup");
            factory.AddDescr(151, "Store forward storage startup");
            factory.AddDescr(152, "Incomplete calculated value");
            factory.AddDescr(202, "Good point of version Latest", ErrQuality.Warning);
            factory.AddDescr(212, "Counter rollover has occurred");
            factory.AddDescr(248, "First value received in store forward mode", ErrQuality.Warning);
            factory.AddDescr(249, "Not a number");
            factory.AddDescr(252, "First value received from IOServer", ErrQuality.Warning);
            factory.AddDescr(65536, "No data stored in history, NULL");
            return(factory);
        }
Ejemplo n.º 4
0
        public void Simple()
        {
            var ed = new ErrDescr(100, "sss", ErrQuality.Error, MomErrType.Calc);

            Assert.AreEqual(100, ed.Number);
            Assert.AreEqual("sss", ed.Text);
            Assert.AreEqual(ErrQuality.Error, ed.Quality);
            Assert.AreEqual(MomErrType.Calc, ed.ErrType);

            var cont = new ContextTest("SimpleContext");
            var em   = new MomErr(ed, cont);

            Assert.IsNotNull(em.AddressLink);
            Assert.IsNotNull(em.ErrDescr);
            Assert.AreEqual("SimpleContext", em.Address);
            Assert.AreEqual(100, em.Number);
            Assert.AreEqual(MomErrType.Calc, em.ErrType);
            Assert.AreEqual(ErrQuality.Error, em.Quality);
            Assert.AreEqual("sss", em.Text);

            var ef = new MomErrFactory("ErrSource", MomErrType.Source)
            {
                UndefinedErrorText = "Ошибка"
            };

            Assert.AreEqual(MomErrType.Source, ef.MomErrType);
            Assert.AreEqual(MomErrType.Source, ef.MomErrType);
            Assert.AreEqual("Ошибка", ef.UndefinedErrorText);
            ef.AddGoodDescr(0);
            ef.AddDescr(1, "Ошибка1", ErrQuality.Warning);
            ef.AddDescr(2, "Ошибка2");
            ef.AddDescr(3, "Ошибка3");

            Assert.IsNull(ef.GetDescr(0));
            Assert.IsNotNull(ef.GetDescr(1));
            var desc = ef.GetDescr(1);

            Assert.AreEqual(1, desc.Number);
            Assert.AreEqual("Ошибка1", desc.Text);
            Assert.AreEqual(ErrQuality.Warning, desc.Quality);
            Assert.AreEqual(MomErrType.Source, desc.ErrType);
            Assert.IsNotNull(ef.GetDescr(2));
            desc = ef.GetDescr(2);
            Assert.AreEqual(2, desc.Number);
            Assert.AreEqual("Ошибка2", desc.Text);
            Assert.AreEqual(ErrQuality.Error, desc.Quality);
            Assert.AreEqual(MomErrType.Source, desc.ErrType);
            Assert.IsNotNull(ef.GetDescr(3));
            desc = ef.GetDescr(3);
            Assert.AreEqual(3, desc.Number);
            Assert.AreEqual("Ошибка3", desc.Text);
            Assert.AreEqual(ErrQuality.Error, desc.Quality);
            Assert.AreEqual(MomErrType.Source, desc.ErrType);
            desc = ef.GetDescr(4);
            Assert.AreEqual(4, desc.Number);
            Assert.AreEqual("Ошибка", desc.Text);
            Assert.AreEqual(ErrQuality.Error, desc.Quality);
            Assert.AreEqual(MomErrType.Source, desc.ErrType);
        }
Ejemplo n.º 5
0
        //Создание фабрики ошибок
        protected override IMomErrFactory MakeErrFactory()
        {
            var factory = new MomErrFactory(ProviderConnect.Code, MomErrType.Source);

            factory.AddGoodDescr(0);
            factory.AddDescr(1, "Предупреждение", ErrQuality.Warning);
            factory.AddDescr(2, "Ошибка");
            return(factory);
        }
Ejemplo n.º 6
0
        //Создание пула ошибок
        private static MomErrPool MakeErrPool()
        {
            var ef = new MomErrFactory("ErrSource", MomErrType.Source);

            ef.AddGoodDescr(0);
            ef.AddDescr(1, "Warning");
            ef.AddDescr(2, "Error");
            return(new MomErrPool(ef));
        }
Ejemplo n.º 7
0
        //Создание фабрики ошибок
        protected override IMomErrFactory MakeErrFactory()
        {
            var factory = new MomErrFactory(ProviderConnect.Code, MomErrType.Source)
            {
                UndefinedErrorText = "Ошибка"
            };

            factory.AddGoodDescr(128);
            return(factory);
        }
Ejemplo n.º 8
0
        //Создание фабрики ошибок
        protected override IMomErrFactory MakeErrFactory()
        {
            var factory = new MomErrFactory(ProviderConnect.Code, MomErrType.Source);

            factory.AddGoodDescr(0);
            factory.AddDescr(1, "FAIR", ErrQuality.Warning);
            factory.AddDescr(2, "POOR", ErrQuality.Warning);
            factory.AddDescr(3, "BAD");
            factory.AddDescr(4, "Нет данных");
            return(factory);
        }
Ejemplo n.º 9
0
        public void Pool()
        {
            var ef = new MomErrFactory("ErrSource", MomErrType.Source);

            ef.AddGoodDescr(0);
            ef.AddDescr(1, "Ошибка1", ErrQuality.Warning);
            ef.AddDescr(2, "Ошибка2");
            ef.AddDescr(3, "Ошибка3");

            var c1   = new ContextTest("Context1");
            var c2   = new ContextTest("Context2");
            var pool = new MomErrPool(ef);

            Assert.AreEqual(0, pool.UsedErrorDescrs.Count());
            var em = pool.MakeError(1, c1);

            Assert.AreEqual("Context1", em.Address);
            Assert.AreEqual(1, em.Number);
            Assert.AreEqual(ErrQuality.Warning, em.Quality);
            Assert.AreEqual("Ошибка1", em.Text);
            em = pool.MakeError(1, c2);
            Assert.AreEqual("Context2", em.Address);
            Assert.AreEqual(1, em.Number);
            Assert.AreEqual(ErrQuality.Warning, em.Quality);
            Assert.AreEqual("Ошибка1", em.Text);
            em = pool.MakeError(1, c1);
            Assert.AreEqual("Context1", em.Address);
            Assert.AreEqual(1, em.Number);
            Assert.AreEqual(ErrQuality.Warning, em.Quality);
            Assert.AreEqual("Ошибка1", em.Text);
            Assert.IsNull(pool.MakeError(0, c2));
            em = pool.MakeError(2, c1);
            Assert.AreEqual("Context1", em.Address);
            Assert.AreEqual(2, em.Number);
            Assert.AreEqual(ErrQuality.Error, em.Quality);
            Assert.AreEqual("Ошибка2", em.Text);
            Assert.AreEqual(2, pool.UsedErrorDescrs.Count());
            pool.ClearErrors();
            em = pool.MakeError(2, c1);
            Assert.AreEqual("Context1", em.Address);
            Assert.AreEqual(2, em.Number);
            Assert.AreEqual(ErrQuality.Error, em.Quality);
            Assert.AreEqual("Ошибка2", em.Text);
            em = pool.MakeError(3, c2);
            Assert.AreEqual("Context2", em.Address);
            Assert.AreEqual(3, em.Number);
            Assert.AreEqual(ErrQuality.Error, em.Quality);
            Assert.AreEqual("Ошибка3", em.Text);
            Assert.AreEqual(2, pool.UsedErrorDescrs.Count());
        }
Ejemplo n.º 10
0
        //Создание фабрики ошибок
        protected override IMomErrFactory MakeErrFactory()
        {
            AddEvent("Создание фабрики ошибок");
            var factory = new MomErrFactory(ProviderConnect.Code, MomErrType.Source);

            using (var rec = new DaoRec(CloneFile, "MomentErrors"))
                while (rec.Read())
                {
                    int    quality = rec.GetInt("Quality");
                    int    num     = rec.GetInt("ErrNum");
                    string text    = rec.GetString("ErrText");
                    factory.AddDescr(num, text, quality);
                }
            return(factory);
        }