示例#1
0
        protected override Action PrepareSignals(Signals signals, Func <Recorder> receiverPrepare)
        {
            var receiver = receiverPrepare.Invoke();

            signals.Add(receiver);
            return(() => { signals.Send(1); });
        }
示例#2
0
 public NotGate(Signal input, Signal output, string name)
 {
     Signals.Add(input);
     Signals.Add(output);
     Name = name;
     Type = GateType.Not;
 }
示例#3
0
文件: Action.cs 项目: orf53975/stetic
        public void CopyFrom(Action action)
        {
            type                        = action.type;
            drawAsRadio                 = action.drawAsRadio;
            radioValue                  = action.radioValue;
            active                      = action.active;
            name                        = action.name;
            GtkAction.HideIfEmpty       = action.GtkAction.HideIfEmpty;
            GtkAction.IsImportant       = action.GtkAction.IsImportant;
            GtkAction.Label             = action.GtkAction.Label;
            GtkAction.Sensitive         = action.GtkAction.Sensitive;
            GtkAction.ShortLabel        = action.GtkAction.ShortLabel;
            GtkAction.StockId           = action.GtkAction.StockId;
            GtkAction.Tooltip           = action.GtkAction.Tooltip;
            GtkAction.Visible           = action.GtkAction.Visible;
            GtkAction.VisibleHorizontal = action.GtkAction.VisibleHorizontal;
            GtkAction.VisibleVertical   = action.GtkAction.VisibleVertical;

            Signals.Clear();
            foreach (Signal s in action.Signals)
            {
                Signals.Add(new Signal(s.SignalDescriptor, s.Handler, s.After));
            }

            NotifyChanged();
        }
示例#4
0
 private void FillSignals()
 {
     foreach (var signal in Fault.Signals)
     {
         Signals.Add(new SignalViewModel(signal));
     }
 }
示例#5
0
 private void ParseNode(XmlNode node)
 {
     foreach (XmlNode signalNode in node.SelectNodes(".//signal"))
     {
         BindingSignal signal = new BindingSignal(signalNode);
         Signals.Add(signal);
     }
 }
示例#6
0
        public ISignal AddSignal(SignalStuff material)
        {
            Signals.Add(new SinSignal(material));
            return(Signals[Signals.Count - 1]);

            //if (AddedSignal != null)
            //    AddedSignal(signal);
        }
示例#7
0
 public override void AddNode(Node s)
 {
     if (s.GetClass() != "Signal")
     {
         return;                                          //Only signals can be added to a device (This is only in the data)
     }
     Signals.Add((Signal)s);
 }
示例#8
0
 protected override Action PrepareSignals(Signals signals, Func <Recorder> receiverPrepare)
 {
     return(() => {
         var receiver = new SignalsTestReceiver();
         signals.Add(receiver);
         signals.Send(1);
         signals.Remove(receiver);
     });
 }
示例#9
0
        private void CreateSignals()
        {
            // change of value signal
            AdapterSignal changeOfAttributeValue = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL);

            changeOfAttributeValue.AddParam(Constants.COV__PROPERTY_HANDLE);
            changeOfAttributeValue.AddParam(Constants.COV__ATTRIBUTE_HANDLE);
            Signals.Add(changeOfAttributeValue);
        }
示例#10
0
        public void AddSignal(SinSignal signal)
        {
            Signals.Add(signal);

            if (AddedSignal != null)
            {
                AddedSignal(signal);
            }
        }
示例#11
0
            /// <summary>
            /// Adds Output Signals from other Analytics to this Device.
            /// </summary>
            public void AddSignals(IEnumerable <AnalyticOutputVM> signals)
            {
                foreach (AnalyticOutputVM s in signals)
                {
                    Signals.Add(new SignalVM(s));
                }

                OnPropertyChanged(nameof(NSignals));
                OnPropertyChanged(nameof(Signals));
            }
        public void PixeyeSignals()
        {
            var signals = new Signals();

            RunMeasure(() => {
                var receiver = new SignalsTestReceiver();
                signals.Add(receiver);
                signals.Send(1);
                signals.Remove(receiver);
            });
        }
示例#13
0
        private void AssignIPtoSignal(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(ImageProcessList.SelectedItem.GetType());
            Console.WriteLine(SignalListView.SelectedIndex);
            SignalHere sh = Signals[SignalListView.SelectedIndex];
            Tmp        tm = (Tmp)ImageProcessList.SelectedItem;

            sh.ImageProcess = tm.Name;
            Signals[SignalListView.SelectedIndex] = sh;
            Signals.Add(sh);
        }
示例#14
0
 public void SetSignalLocation(Location location, double areaLength)
 {
     var signal = new SignalCell(location, areaLength);
     for (int i = 0; i < Cells.Count; i++)
     {
         if (location.DistanceTo(Cells[i].Location) < areaLength)
         {
             signal.AxsonConnectedID.Add(Cells[i].ID);
         }
     }
     Signals.Add(signal);
 }
示例#15
0
        public AssignSignal(List <Signal> signalList, List <String> tmp)
        {
            foreach (Signal s in signalList)
            {
                Signals.Add(new SignalHere(s));
            }

            foreach (String s in tmp)
            {
                ImageProcesses.Add(new Tmp(s));
            }

            InitializeComponent();
        }
示例#16
0
        public void ReadInput()
        {
            var path = Path.Combine(Directory.GetCurrentDirectory(), InputFile);

            using (var reader = File.OpenText(path))
            {
                var line = reader.ReadLine();
                while (line is not null)
                {
                    Signals.Add(new Signal(line.Split('|')[0].Trim().Split(' ').ToList(), line.Split('|')[1].Trim().Split(' ').ToList()));
                    line = reader.ReadLine();
                }
            }
        }
示例#17
0
        public void GenerateSignals()
        {
            int deltaM = N / 4 / 8;

            M = N * NMulCoef;

            for (int i = deltaM; i < M; i++)
            {
                GarmonicSignal newSignal = new SinusoidalSignal(i, N, Phase);
                newSignal.Generate();
                newSignal.CalculateCharacteristics();
                Signals.Add(newSignal);
            }
        }
示例#18
0
        public void AddSignal(ISignal signal)
        {
            int count = Signals.Count(c => c.Name.Contains(signal.Name));

            signal.Name = count != 0 ? $"{ signal.Name}({count})" : signal.Name;
            if (signal.GetType() == typeof(SampledSignal))
            {
                SampledSignals.Add((SampledSignal)signal);
            }
            if (signal.GetType() == typeof(ContinuousSignal))
            {
                ContinuousSignals.Add((ContinuousSignal)signal);
            }
            Signals.Add(signal);
        }
示例#19
0
 public void AddSignal(Signal signalIn)
 {
     // 特殊ID表示该报文作为未使用信号的容器,不必检查新信号的合法性
     if (ID != 0xC0000000)
     {
         if (signalIn.Message != null)
         {
             throw new ApplicationException("Signal already belongs to message: " + signalIn.Message.Name);
         }
         if (!CheckSignalPosition(signalIn))
         {
             throw new ApplicationException("Signal position doesn't fit in message layout");
         }
     }
     AddChild(signalIn);
     Signals.Add(signalIn.Name, signalIn);
 }
        private void LoadSignalsFromActiveWorkBook()
        {
            Signals.Clear();
            SignalViews.Clear();

            List <Signal> signals = new List <Signal>(workBookManager.ActiveWorkBook().Signals.Values);

            // No addrange for observeablecollection
            foreach (Signal signal in signals.Where(sig => sig.Type == SignalType.Source))
            {
                signal.PropertyChanged -= handleSignalUpdate;
                Signals.Add(signal);
                SignalViews.Add(new SignalItemView {
                    DataContext = signal
                });
                signal.PropertyChanged += handleSignalUpdate;
            }
        }
示例#21
0
        public double[] AddSignalBySize(int start, int dur, double offset, double freq, double mult, double constant, double fading)
        {
            var gen    = new SinGenerator(start, dur, offset, freq, mult, constant, fading);
            var signal = gen.GenerateSin();

            for (var i = 0; i < signal.Length; i++)
            {
                Sum[(start + i) % Sum.Length] += signal[i];
            }

            Signals.Add(gen);

            if (AddedSignal != null)
            {
                AddedSignal(gen, Signals.Count - 1);
            }

            return(signal);
        }
示例#22
0
        public Signal AddSignal(int index, TradeType tradeType, double?stopLoss, double?takeProfit, string comment)
        {
            if (_newSignalSettings == null)
            {
                throw new NullReferenceException("The signal container NewSignalSettings object is null");
            }

            RemoveSignal(index, tradeType);

            var signal = new Signal
            {
                Index      = index,
                Time       = _newSignalSettings.Bars.OpenTimes[index],
                Symbol     = _symbol,
                TradeType  = tradeType,
                StopLoss   = stopLoss,
                TakeProfit = takeProfit,
                Comment    = comment
            };

            Signals.Add(signal);

            _newSignalSettings.AlertCallback?.Invoke(index, tradeType);

            if (tradeType == TradeType.Buy && _newSignalSettings.BuyEntry != null)
            {
                _newSignalSettings.BuyEntry[index] = _newSignalSettings.Bars.LowPrices[index] - _newSignalSettings.SignalDistance;
            }
            else if (tradeType == TradeType.Sell && _newSignalSettings.SellEntry != null)
            {
                _newSignalSettings.SellEntry[index] = _newSignalSettings.Bars.HighPrices[index] + _newSignalSettings.SignalDistance;
            }

            if (_newSignalSettings.IsExportEnabled)
            {
                Export();
            }

            return(signal);
        }
        private void ProcessRule(List <SignalDetail> items)
        {
            foreach (var item in items)
            {
                var value = item.Rule.Split(' ');
                var last  = value.LastOrDefault();

                if (string.Compare(dict[item.Signal].ValueType, "integer") == 0)
                {
                    var itemValue = Convert.ToInt32(dict[item.Signal].Value);
                    var ruleValue = Convert.ToInt32(last);

                    if ((item.Rule.Contains("greater than") && itemValue > ruleValue) ||
                        (item.Rule.Contains("less than") && itemValue < ruleValue) ||
                        item.Rule.Contains("equal to") && itemValue == ruleValue)
                    {
                        dict[item.Signal].IsTrue = true;
                    }
                }

                if (string.Compare(dict[item.Signal].ValueType, "string") == 0)
                {
                    var itemValue = dict[item.Signal].Value;
                    var ruleValue = last;

                    if (item.Rule.Contains("not be"))
                    {
                        if (!string.Equals(itemValue, ruleValue))
                        {
                            dict[item.Signal].IsTrue = true;
                        }
                    }
                    else
                    {
                        dict[item.Signal].IsTrue = true;
                    }
                }

                if (string.Compare(dict[item.Signal].ValueType, "Datetime") == 0)
                {
                    var itemValue = Convert.ToDateTime(dict[item.Signal].Value);
                    var now       = DateTime.Now;
                    var result    = DateTime.Compare(itemValue, now);

                    if (item.Rule.Contains("future") && result == 1 ||
                        item.Rule.Contains("past") && result == -1 ||
                        item.Rule.Contains("present") && result == 0)
                    {
                        dict[item.Signal].IsTrue = true;
                    }
                }

                foreach (var dictionaryValue in dict)
                {
                    if (dictionaryValue.Value.IsTrue)
                    {
                        Signals.Add(dictionaryValue.Value);
                    }
                }
            }
        }
示例#24
0
 public void Add(JournalFSSSignalDiscovered next)
 {
     Signals.Add(next.Signals[0]);
 }
示例#25
0
 private void OnSignal(Signal signal)
 {
     Signals.Add(signal);
 }
示例#26
0
 //Добавить сигнал
 public override ProxySignal AddSignal(IReadingConnect connect, IReadSignal signal) //Оборачиваемый сигнал
 {
     lock (ValuesLocker)
         return(Signals.Add(connect.Code + "." + signal.Code, new QueuedProxySignal(connect.Code, signal)));
 }
示例#27
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;
                }
            }
        }
示例#28
0
        /// <summary>
        /// Initializes the module. Loads all modules and signals
        /// </summary>
        /// <returns></returns>
        public void Initialize()
        {
            //Instance of the simulator
            Simulator sim = Simulator.GetInstance();

            //Used for errors, false if errors
            bool ok = true;

            if (Parent != null)
            {
                Parent.Children.Add(this);

                this.name = Parent.Name + "." + this.name;

                int i = 0;
                foreach (ModuleBase mb in Parent.Children)
                {
                    if (mb.name.StartsWith(this.name))
                    {
                        i++;
                    }
                }
                this.name += i.ToString();
            }

            //Initialize arrays
            sigs = new List <SignalBase>();

            //Add handler for simulator first step
            sim.FirstStep += new EmptyHandler(First);

            //Add handler for simulator before stop
            sim.OnStop += new EmptyHandler(OnStop);

            //Add handler for simulator after loading
            sim.Load += new EmptyHandler(OnLoad);

            //Add module to simulator
            // sim.AddModule(this);

            //Holder for signals found
            Dictionary <string, SignalBase> signals = new Dictionary <string, SignalBase>();

            //All fields in this class
            FieldInfo[] fis = this.GetType().GetFields();

            //Find all signals in this module and store them
            foreach (FieldInfo fi in fis)
            {
                Type t = fi.FieldType;

                //Check if the type is a subclass of Signalbase
                if (t.IsSubclassOf(typeof(SignalBase)))
                {
                    //Get the value of the filed
                    object o = this.GetType().InvokeMember(fi.Name, BindingFlags.GetField, null, this, new object[] { });

                    //If the value is null there is something
                    if (o == null)
                    {
                        sim.SendError(this.GetType() + ": Connection Error: " + fi.Name + " has no instance.");
                        ok = false;
                        continue;
                    }

                    //Cast to signalBase
                    SignalBase c = (SignalBase)o;

                    //Sets the fullname of the signal
                    if (this.Name == null)
                    {
                        c.FullName = fi.Name;
                    }
                    else
                    {
                        c.FullName = this.Name + "." + fi.Name;
                    }

                    //Sets the name of the signal
                    c.Name = fi.Name;

                    //Adds the signal to the module
                    Signals.Add(c);

                    //Stores the signals
                    signals.Add(fi.Name, c);
                }
            }

            //Find all signals that are properties and store them
            PropertyInfo[] pis = this.GetType().GetProperties();
            foreach (PropertyInfo pi in pis)
            {
                Type t = pi.PropertyType;

                //Check if the type is a subclass of Signalbase
                if (t.IsSubclassOf(typeof(SignalBase)))
                {
                    //Get the value of the filed
                    object o = pi.GetValue(this, new object[] { });

                    //If the value is null there is something
                    if (o == null)
                    {
                        sim.SendError(this.GetType() + ": Connection Error: " + pi.Name + " has no instance.");
                        ok = false;
                        continue;
                    }

                    //Cast to signalBase
                    SignalBase c = (SignalBase)o;

                    if (Signals.Contains(c))
                    {
                        continue;
                    }

                    //Sets the fullname of the signal
                    if (this.Name == null)
                    {
                        c.FullName = pi.Name;
                    }
                    else
                    {
                        c.FullName = this.Name + "." + pi.Name;
                    }

                    //Sets the name of the signal
                    c.Name = pi.Name;

                    //Adds the signal to the module
                    Signals.Add(c);

                    //Stores the signals
                    signals.Add(pi.Name, c);
                }
            }

            //Get all methods
            MethodInfo[] mis = this.GetType().GetMethods();
            //EmptyHandler eh;
            ProcessWorker pw;

            foreach (MethodInfo mi in mis)
            {
                object[] o = mi.GetCustomAttributes(typeof(ProcessAttribute), true);
                //If the method uses the process attribute
                if (o.Length > 0)
                {
                    //Run through all sensitive attributes
                    foreach (ProcessAttribute sa in o)
                    {
                        //Run through all signal names in process attribute
                        foreach (string name in sa.SignalNames)
                        {
                            if (signals.ContainsKey(name))
                            {
                                //If the method is sensitive to the signal add it to the signals list of methods to run
                                signals[name].SensType = sa.SensType;
                                //eh = (EmptyHandler)Delegate.CreateDelegate(typeof(EmptyHandler), this, mi.Name);
                                pw = new ProcessWorker(this, mi);
                                signals[name].Changed += new EmptyHandler(pw.Run);
                            }
                            else
                            {
                                //If the signal was not found call an error
                                sim.SendError(this.GetType() + ": Senstitivity Error: Could not find signal " + name + " that is needed by " + mi.Name);
                                ok = false;
                            }
                        }
                    }
                }
            }

            if (!ok)
            {
                throw new CommandException("Initialize of " + this.Name + " failed");
            }

            InitComplete = true;
        }
示例#29
0
        //Загрузить список сигналов, возвращает ошибку или ""
        public string LoadSignals()
        {
            StartAtom(Atom.LoadSignals);
            CountsToZero();
            if (State == State.Closed)
            {
                AddError("Копилятор уже был закрыт");
            }
            else if (State == State.Empty)
            {
                AddError("Проект не загружен");
            }
            else
            {
                try
                {
                    var objectsId = new DicI <ObjectSignal>();
                    Signals.Clear();
                    SignalsList.Clear();
                    //using (var db = new DaoDb(_projectFile))
                    using (var db = new DaoDb(_objectsFile)) //ab\
                    {
                        using (var reco = new ReaderAdo(db, "SELECT CodeObject, NameObject, TagObject, ObjectId, CommName FROM Objects ORDER BY ObjectId"))
                        {
                            AddEvent("Открыт рекордсет объектов");
                            Procent = 5;
                            while (reco.Read())
                            {
                                var curo = new ObjectSignal(reco, false);
                                Objects.Add(curo.Code, curo);
                                objectsId.Add(curo.Id, curo);
                            }
                            AddEvent("Объекты загружены");
                        }
                        Thread.Sleep(50);

                        Procent = 20;
                        using (var recs = new ReaderAdo(db, "SELECT ObjectId, Default, CodeSignal, NameSignal, Units, DataType, ConstValue, SourceName, ReceiverName, Inf, FullCode FROM Signals ORDER BY ObjectId, SignalId"))
                        {
                            int i = 0, n = recs.RecordCount("SELECT Count(*) FROM Signals");
                            Procent = 30;
                            AddEvent("Открыт рекордсет сигналов");
                            if (n != 0)
                            {
                                while (recs.Read())
                                {
                                    var sig = new Signal(recs, objectsId, false);
                                    SignalsList.Add(sig);
                                    Signals.Add(sig.FullCode, sig);
                                    if (sig.Default && objectsId.ContainsKey(sig.ObjectId))
                                    {
                                        Signals.Add(objectsId[sig.ObjectId].Code, sig);
                                    }
                                    if (n > 20 && i % (n / 15) == 0)
                                    {
                                        Procent = (i++ *70) / n + 30;
                                    }
                                }
                            }
                        }
                        AddEvent("Сигналы загружены");
                    }
                }
                catch (Exception ex)
                {
                    //ab
                    //AddError("Ошибка загрузки сигналов", ex);
                    AddError("Ошибка загрузки сигналов: " + ex.Message, ex);
                    //\ab
                }
            }
            return(FinishAtom(State.Signals, State.Project, "Проект: " + _code + @";  Сигналов: " + SignalsList.Count));
        }
示例#30
0
 public void Add(Signal s)
 {
     Signals.Add(s);
     s._parent = this;
 }