Example #1
0
        public void ParseFromVectorDbcString(string line)
        {
            // split signal line into two
            var halfsplit = Regex.Split(line, DbcHalfPattern);
            // split 2nd half of signal
            var split2ndpart = Regex.Split(halfsplit[2], DbcSignalSecondHalfPattern);
            var rawsplit     = Regex.Split(split2ndpart[0].Trim(), VectorDbcPattern);

            // split 1st half of signal
            halfsplit = Regex.Split(halfsplit[0], @"[^\w]+");

            try
            {
                //// This is invariant
                //NumberFormatInfo format = new NumberFormatInfo();
                //// Set the decimal seperator
                //format.NumberDecimalSeparator = ".";
                FieldName = halfsplit[2];
                StartBit  = int.Parse(rawsplit[0]);
                LengthBit = int.Parse(rawsplit[1]);
                //Factor = double.Parse(rawsplit[3], format);
                //Offset = double.Parse(rawsplit[4], format);
                Factor    = double.Parse(rawsplit[3]);
                Offset    = double.Parse(rawsplit[4]);
                RawOffset = (int)(Offset / Factor);
                //MinValue = double.Parse(rawsplit[5], format);
                //MaxValue = double.Parse(rawsplit[6], format);
                MinValue = double.Parse(rawsplit[5]);
                MaxValue = double.Parse(rawsplit[6]);
                Order    = (rawsplit[2].Contains("1")) ? BitLayout.Intel : BitLayout.Motorolla;
                Signed   = (rawsplit[2].Contains("-"));
                SigType  = GetSigType();
            }
            catch (Exception e)
            {
                Console.WriteLine($"(!)Parsing exception occured in line'{line}'.{Environment.NewLine}" +
                                  $"Text: {e.Message}");
            }

            FieldUnit = "-";

            if (split2ndpart.Length == 3)
            {
                FieldUnit = split2ndpart[1];
            }

            var receivers = Regex.Split(split2ndpart.Last().Trim(), VectorDbcPattern);

            Receivers.Clear();

            foreach (var rx in receivers)
            {
                Receivers.Add(rx);
            }
        }
Example #2
0
 public void Clear()
 {
     Quarterback.Clear();
     Receivers.Clear();
     Runningbacks.Clear();
     OffensiveLinemen.Clear();
     TightEnds.Clear();
     Cornerbacks.Clear();
     Linebackers.Clear();
     DefensiveLinemen.Clear();
     Safeties.Clear();
 }
Example #3
0
 public void Clear()
 {
     Receivers.Clear();
     Runningbacks.Clear();
     OffensiveLinemen.Clear();
     TightEnds.Clear();
     Cornerbacks.Clear();
     Linebackers.Clear();
     DefensiveLinemen.Clear();
     Safeties.Clear();
     allPositions.Clear();
     offensivePositions.Clear();
     defensivePositions.Clear();
 }
Example #4
0
        public void Stop()
        {
            if (IsStarted)
            {
                IsStarted = false;
                Listener.Stop();

                for (int i = Receivers.Count - 1; i >= 0; --i)
                {
                    Receivers[i].Disconnect();
                }

                Receivers.Clear();
            }
        }
Example #5
0
        //Загружет списки проектов и провайдеров для потока
        public void ReadSetup()
        {
            try
            {
                Projects.Clear();
                ProjectsList.Clear();
                foreach (var provider in ProvidersDic.Values)
                {
                    var pi = provider.ProviderInstance;
                    if (pi != null)
                    {
                        if (ApplicationType == ApplicationType.Controller && General.ProvidersQueues.ContainsKey(pi.Hash))
                        {
                            General.ProvidersQueues.Remove(pi.Hash);
                        }
                        pi.Dispose();
                    }
                }

                ProvidersDic.Clear();
                Sources.Clear();
                Receivers.Clear();
                Imitators.Clear();
                Archive   = null;
                ArchivePr = null;

                using (var rec = new RecDao(General.ControllerFile, "SELECT * FROM Projects WHERE ThreadId =" + Id + " ORDER BY Project"))
                    while (rec.Read())
                    {
                        var proj = new Project(rec, this);
                        if (!Command.IsError && !Projects.ContainsKey(proj.Code))
                        {
                            Projects.Add(proj.Code, proj);
                            ProjectsList.Add(proj);
                            AddEvent("Добавлен проект", proj.Code + ", " + proj.File);
                            proj.ReadProviders();//Чтение списка провайдеров
                        }
                    }
                MakeProviders();
                MakeProjectString();
            }
            catch (Exception ex)
            {
                AddError("Ошибка загрузки списка проектов. Необходимо повторить настройку", ex);
            }
            Procent = 70;

            try //Список провайдеров
            {
                AddEvent("Чтение настроек провайдеров");
                using (var rec = new RecDao(General.ControllerFile, "SELECT * FROM Providers WHERE ThreadId =" + Id))
                    while (rec.Read())
                    {
                        var name = rec.GetString("ProviderName");
                        if (ProvidersDic.ContainsKey(name))
                        {
                            var prov = ProvidersDic[name];
                            prov.Code = rec.GetString("ProviderCode");
                            prov.Inf  = rec.GetString("ProviderInf");
                            prov.Otm  = rec.GetBool("Otm");
                        }
                    }
                foreach (var prov in ProvidersDic.Values)
                {
                    if (prov.Otm)
                    {
                        prov.ProviderInstance = General.RunProvider(prov.Code, prov.Name, prov.Inf, this);
                        if (prov.ProviderInstance != null)
                        {
                            switch (prov.Type.ToProviderType())
                            {
                            case ProviderType.Archive:
                                Archive   = (IArchive)prov.ProviderInstance;
                                ArchivePr = prov;
                                break;

                            case ProviderType.Source:
                                Sources.Add(prov.Name, (ISource)prov.ProviderInstance);
                                break;

                            case ProviderType.Imitator:
                                var ims = (Imitator)prov.ProviderInstance;
                                Imitators.Add(prov.Name, ims);
                                var pname = prov.Name.Substring(0, prov.Name.Length - 4);
                                if (Projects.ContainsKey(pname))
                                {
                                    Projects[pname].Imitator = ims;
                                }
                                else
                                {
                                    AddError("Недопустимое имя провайдера имитатора", null, prov.Name);
                                }
                                break;

                            case ProviderType.Receiver:
                                Receivers.Add(prov.Name, (IReceiver)prov.ProviderInstance);
                                break;
                            }
                            if (ApplicationType == ApplicationType.Controller)
                            {
                                string hash = prov.ProviderInstance.Hash;
                                if (!General.ProvidersQueues.ContainsKey(hash))
                                {
                                    General.ProvidersQueues.Add(hash, new Queue <int>());
                                }
                                prov.ProviderQueue = General.ProvidersQueues[hash];
                            }
                        }
                    }
                }
                MakeProviders();
            }
            catch (Exception ex)
            {
                AddError("Ошибка при чтении настроек провайдеров", ex);
            }
        }