Пример #1
0
 public void SignalRegistryClearTest()
 {
     Signals.Get <TestSignal>();
     Assert.IsTrue(Signals.Count == 1);
     Signals.Clear();
     Assert.IsTrue(Signals.Count == 0);
 }
Пример #2
0
        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();
        }
Пример #3
0
        protected virtual void ReadProperties(ObjectReader reader, XmlElement elem)
        {
            if (Wrapped != null)
            {
                // There is already an instance. Load the default values.
                this.ClassDescriptor.ResetInstance(Wrapped);
                Signals.Clear();
            }

            if (reader.Format == FileFormat.Native)
            {
                WidgetUtils.Read(this, elem);
            }
            else
            {
                GladeUtils.ImportWidget(this, elem);
            }

            string uid = elem.GetAttribute("undoId");

            if (uid.Length > 0)
            {
                UndoId = uid;
            }
            oldName = Wrapped.Name;
        }
Пример #4
0
 private void OnReset()
 {
     SignalDictionary.Clear();
     Signals.Clear();
     SelectedRule     = null;
     SelectedTemplate = null;
 }
        /// <summary>
        /// Метод изменения значения сигнала
        /// </summary>
        /// <param name="robot">экземпляр подключения к роботу</param>
        /// <param name="ioTypeConstant">константа типа сигнала</param>
        /// <param name="index">индекс сигнала, значение которое нужно изменить</param>
        /// <param name="value">новое значение сигнала</param>
        private async void SetSignalsIO(FRCRobot robot, FREIOTypeConstants ioTypeConstant, long index, bool value)
        {
            try
            {
                if (robot.IsConnected)
                {
                    switch (ioTypeConstant)
                    {
                    case FREIOTypeConstants.frDInType:
                    case FREIOTypeConstants.frDOutType:
                        FRCDigitalIOSignal dioSignal = (FRCDigitalIOSignal)((FRCDigitalIOType)robot.IOTypes[ioTypeConstant]).Signals[index];
                        dioSignal.Value = value;
                        dioSignal.Update();
                        break;

                    case FREIOTypeConstants.frUOPInType:
                    case FREIOTypeConstants.frUOPOutType:
                        FRCUOPIOSignal uop = (FRCUOPIOSignal)((FRCUOPIOType)robot.IOTypes[ioTypeConstant]).Signals[index];
                        uop.Value = value;
                        uop.Update();
                        break;

                    case FREIOTypeConstants.frSOPInType:
                    case FREIOTypeConstants.frSOPOutType:
                        FRCSOPIOSignal sop = (FRCSOPIOSignal)((FRCSOPIOType)robot.IOTypes[ioTypeConstant]).Signals[index];
                        sop.Value = value;
                        sop.Update();
                        break;

                    case FREIOTypeConstants.frFlagType:
                        FRCFlagSignal flagSignal = (FRCFlagSignal)((FRCFlagType)robot.IOTypes[ioTypeConstant]).Signals[index];
                        flagSignal.Value = value;
                        flagSignal.Update();
                        break;

                    case FREIOTypeConstants.frRDInType:
                    case FREIOTypeConstants.frRDOutType:
                        FRCRobotIOSignal rd = (FRCRobotIOSignal)((FRCRobotIOType)robot.IOTypes[ioTypeConstant]).Signals[index];
                        rd.Value = value;
                        rd.Update();
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                Signals.Clear();
                await GetSignalsIO(robot, ioTypeConstant);
            }
        }
Пример #6
0
        public void SignalRegistryGetMethodsTest()
        {
            Signals.Clear();
            TestSignal testSignal0;
            TestSignal testSignal1;
            TestSignal testSignal2;

            testSignal0 = Signals.Get <TestSignal>();
            Signals.Get(out testSignal1);
            testSignal2 = (TestSignal)Signals.Get(typeof(TestSignal));

            Assert.IsTrue(testSignal0 == testSignal1);
            Assert.IsTrue(testSignal0 == testSignal2);
        }
Пример #7
0
 public void Clean()
 {
     Signals.Clear();
     StartTimeStamps.Clear();
     EndTimeStamps.Clear();
     TimePairs.Clear();
     FirstFile     = true;
     ResumedTask   = false;
     DataCompleted = false;
     FinishedSignatures.Clear();
     _results.Clear();
     _doneDataWriterFlags.Clear();
     //FirstFileRead = false;
 }
Пример #8
0
        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;
            }
        }
Пример #9
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));
        }
Пример #10
0
 public void Setup()
 {
     Signals.Clear();
 }
        /// <summary>
        /// Получение списка сигналов и передача в список Signals
        /// </summary>
        /// <param name="robot">экземпляр подключения к роботу</param>
        /// <param name="ioTypeConstant">константа типа сигналов</param>
        /// <returns>возвращаемое значение-текущая задача</returns>
        private async Task GetSignalsIO(FRCRobot robot, FREIOTypeConstants ioTypeConstant)
        {
            Task task = new Task(() =>
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    try
                    {
                        if (robot.IsConnected)
                        {
                            Signals.Clear();
                            switch (ioTypeConstant)
                            {
                            //DIN DOUT
                            case FREIOTypeConstants.frDOutType:
                            case FREIOTypeConstants.frDInType:
                                FRCDigitalIOType dioTypeIn = (FRCDigitalIOType)robot.IOTypes[ioTypeConstant];
                                foreach (FRCDigitalIOSignal item in dioTypeIn.Signals)
                                {
                                    Signals.Add(new IOSignals {
                                        NumberIO = item.LogicalNum, Status = item.Value,
                                        Comment  = item.Comment, TypeConstants = ioTypeConstant
                                    });
                                }

                                break;

                            //UI UO
                            case FREIOTypeConstants.frUOPInType:
                            case FREIOTypeConstants.frUOPOutType:
                                FRCUOPIOType TypeUO = (FRCUOPIOType)robot.IOTypes[ioTypeConstant];
                                foreach (FRCUOPIOSignal item in TypeUO.Signals)
                                {
                                    Signals.Add(new IOSignals {
                                        NumberIO = item.LogicalNum, Status = item.Value,
                                        Comment  = item.Comment, TypeConstants = ioTypeConstant
                                    });
                                }
                                break;

                            //SI SO
                            case FREIOTypeConstants.frSOPInType:
                            case FREIOTypeConstants.frSOPOutType:
                                FRCSOPIOType TypeSO = (FRCSOPIOType)robot.IOTypes[ioTypeConstant];
                                foreach (FRCSOPIOSignal item in TypeSO.Signals)
                                {
                                    Signals.Add(new IOSignals {
                                        NumberIO = item.LogicalNum, Status = item.Value, Comment = item.Comment, TypeConstants = ioTypeConstant
                                    });
                                }
                                break;

                            //FLAG
                            case FREIOTypeConstants.frFlagType:
                                FRCFlagType TypeFlag = (FRCFlagType)robot.IOTypes[ioTypeConstant];
                                foreach (FRCFlagSignal item in TypeFlag.Signals)
                                {
                                    Signals.Add(new IOSignals {
                                        NumberIO = item.LogicalNum, Status = item.Value, Comment = item.Comment, TypeConstants = ioTypeConstant
                                    });
                                }
                                break;

                            //RO RI
                            case FREIOTypeConstants.frRDOutType:
                            case FREIOTypeConstants.frRDInType:
                                FRCRobotIOType TypeRI = (FRCRobotIOType)robot.IOTypes[ioTypeConstant];
                                foreach (FRCRobotIOSignal item in TypeRI.Signals)
                                {
                                    Signals.Add(new IOSignals {
                                        NumberIO = item.LogicalNum, Status = item.Value, Comment = item.Comment, TypeConstants = ioTypeConstant
                                    });
                                }
                                break;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }));
            }, TaskCreationOptions.LongRunning);

            task.Start();
            await task;
        }
Пример #12
0
 public void FinalTearDown()
 {
     Signals.Clear();
 }
Пример #13
0
 public void InitialSetup()
 {
     callLog.Clear();
     Signals.Clear();
     Signals.Get(out signal);
 }