Beispiel #1
0
 /// <summary>
 /// Enables the specified trading signal.
 /// </summary>
 /// <param name="name">The name.</param>
 public void EnableSignal(string name)
 {
     if (Signals.ContainsKey(name))
     {
         Signals[name].IsEnabled = true;
     }
 }
Beispiel #2
0
        public void AddData(List <Signal> e)
        {
            if (e != null && e.Count > 0)
            {
                var startT = e.FirstOrDefault().TimeStamps.FirstOrDefault();
                if (FirstFile)
                {
                    TimeZero = startT;
                    //FirstFileRead = true;
                    FirstFile = false;
                }
                //else if (TimeZero >= startT)
                //{
                //    throw new Exception("Possible data source files time order problem.");
                //}
                var endT = e.FirstOrDefault().TimeStamps.LastOrDefault();
                //Console.WriteLine("Added end timestamp: " + endT.ToString("yyyyMMdd_HHmmss.ffffff") + " in " + e.FirstOrDefault().TimeStamps.Count() + " timestamps.");
                foreach (var sig in e)
                {
                    var name = sig.PMUName + "_" + sig.SignalName;

                    lock (_theInputSignalsLock)
                    {
                        if (!Signals.ContainsKey(name))
                        {
                            Signals[name] = new Dictionary <DateTime, Signal>();
                        }
                        Signals[name][endT] = sig;
                    }
                }
                lock (_theDataWriterLock)
                {
                    if (!_doneDataWriterFlags.ContainsKey(endT))
                    {
                        _doneDataWriterFlags[endT] = new List <bool>();
                    }
                    TimePairs[startT] = endT;
                    StartTimeStamps.Add(startT);
                }
                lock (_theEndTimeStampsLock)
                {
                    EndTimeStamps.Add(endT);
                }
            }
        }
Beispiel #3
0
        //Запись используемых сигналов в SignalsInUse
        private void SaveInUse()
        {
            try
            {
                using (var db = new DaoDb(_projectFile))
                {
                    var old = new SetS();
                    using (var rec = new RecDao(db, "SignalsInUse"))
                    {
                        while (rec.Read())
                        {
                            var code = rec.GetString("FullCode");
                            if ((Signals.ContainsKey(code) && Signals[code].InUse) || HandSignals.ContainsKey(code))
                            {
                                old.Add(code);
                                rec.Put("Del", false);
                            }
                            else
                            {
                                rec.Put("Del", true);
                            }
                        }
                    }
                    db.Execute("DELETE * FROM SignalsInUse WHERE Del=True");
                    var add = new SetS();
                    var use = from s in SignalsList where s.InUse select s;
                    SignalsInUseCount = use.Count();
                    foreach (var s in use)
                    {
                        if (!old.Contains(s.FullCode))
                        {
                            add.Add(s.FullCode);
                        }
                        if (s.InUseSource)
                        {
                            UsedProviders.Add(s.SourceName);
                        }
                        if (s.InUseReceiver)
                        {
                            UsedProviders.Add(s.ReceiverName);
                        }
                    }
                    if (HandSignals.Count > 0 && HandInputSource != null)
                    {
                        UsedProviders.Add(HandInputSource);
                    }
                    foreach (var hand in HandSignals.Values)
                    {
                        if (!old.Contains(hand.FullCode))
                        {
                            add.Add(hand.FullCode);
                        }
                    }

                    using (var rec = new RecDao(db, "SignalsInUse"))
                    {
                        while (rec.Read())
                        {
                            var    s   = rec.GetString("FullCode");
                            Signal sig = Signals.ContainsKey(s) ? Signals[s] : HandSignals[s];
                            sig.ToRecordset(rec, false);
                        }
                        foreach (var s in add.Keys)
                        {
                            Signal sig = Signals.ContainsKey(s) ? Signals[s] : HandSignals[s];
                            sig.ToRecordset(rec, true);
                        }
                    }
                    using (var rec = new RecDao(db, "GraficsList"))
                        while (rec.Read())
                        {
                            rec.Put("UsedUnits", UsingParamsString(Grafics[rec.GetString("Code")].UsingParams));
                        }
                }
            }
            catch (Exception ex)
            {
                AddError("Ошибка сохранения сигналов или графиков", ex);
            }
        }
Beispiel #4
0
        protected ObjectBase(XmlElement namespaceElement, XmlElement element, bool isInterface) : base(namespaceElement, element)
        {
            _isInterface = isInterface;
            XmlElement classElement = null;

            var virtualMethods       = new Dictionary <string, XmlElement>();
            var signalVirtualMethods = new Dictionary <string, XmlElement>();

            if (ParserVersion == 1)
            {
                ClassStructName = $"{CName}{(isInterface ? "Iface" : "Class")}";
            }

            foreach (XmlNode node in element.ChildNodes)
            {
                if (!(node is XmlElement))
                {
                    continue;
                }
                var member = node as XmlElement;

                switch (node.Name)
                {
                case Constants.VirtualMethod:
                    if (ParserVersion == 1 && isInterface)
                    {
                        // Generating non-signal GObject virtual methods is not supported in compatibility mode
                        AddVirtualMethod(member, false, true);
                    }
                    else
                    {
                        virtualMethods.Add(member.GetAttribute(Constants.CName), member);
                    }
                    break;

                case Constants.Signal:
                    if (ParserVersion == 1 || member.GetAttribute(Constants.FieldName) == "")
                    {
                        AddVirtualMethod(member, true, isInterface);
                    }
                    else
                    {
                        signalVirtualMethods.Add(member.GetAttribute(Constants.FieldName), member);
                    }

                    if (!member.GetAttributeAsBoolean(Constants.Hidden))
                    {
                        var cName = member.GetAttribute(Constants.CName);

                        while (Signals.ContainsKey(cName))
                        {
                            cName += "mangled";
                        }

                        Signals.Add(cName, new Signal(member, this));
                    }
                    break;

                case "class_struct":
                    classElement = member;
                    break;
                }
            }

            if (classElement == null)
            {
                return;
            }

            if (classElement.GetAttributeAsBoolean("private"))
            {
                _classAbiValid = false;
                return;
            }

            ClassStructName = classElement.GetAttribute(Constants.CName);

            var numAbiFields = 0;

            for (var index = 0; index < classElement.ChildNodes.Count; index++)
            {
                var node = classElement.ChildNodes[index];
                if (!(node is XmlElement))
                {
                    continue;
                }

                var member = (XmlElement)node;

                switch (node.Name)
                {
                // Make sure ABI fields are taken into account, even when hidden.
                case Constants.Field:
                {
                    numAbiFields += 1;

                    // Skip instance parent struct
                    if (numAbiFields != 1)
                    {
                        AbiClassMembers.Add(new StructAbiField(member, this, "class_abi"));
                    }

                    break;
                }

                case Constants.Method:
                    AbiClassMembers.Add(new MethodAbiField(member, this, "class_abi"));
                    break;

                case "union":
                    AbiClassMembers.Add(new UnionAbiField(member, this, "class_abi"));
                    break;
                }

                switch (member.Name)
                {
                case Constants.Method:
                    var isSignalVirtualMethod = member.HasAttribute("signal_vm");

                    string     virtualMethodName;
                    XmlElement virtualMethodElement;

                    if (isSignalVirtualMethod)
                    {
                        virtualMethodName    = member.GetAttribute("signal_vm");
                        virtualMethodElement = signalVirtualMethods[virtualMethodName];
                    }
                    else
                    {
                        virtualMethodName    = member.GetAttribute("vm");
                        virtualMethodElement = virtualMethods[virtualMethodName];
                    }

                    AddVirtualMethod(virtualMethodElement, isSignalVirtualMethod, isInterface);
                    break;

                case Constants.Field:
                    if (index == 0)
                    {
                        continue;                 // Parent class
                    }
                    var field = new ClassField(member, this);

                    ClassFields.Add(field);
                    _classMembers.Add(field);
                    break;

                default:
                    Console.WriteLine($"Unexpected node {member.Name} in {classElement.GetAttribute(Constants.CName)}.");
                    break;
                }
            }
        }