예제 #1
0
        public void Load(string xmlFile)
        {
            if (!File.Exists(xmlFile))
            {
                return;
            }

            var xml = File.ReadAllText(xmlFile);

            if (string.IsNullOrEmpty(xml))
            {
                return;
            }
            var config = Serializer.Deserialize(xml);

            Sessions.Clear();
            Connections.Clear();
            Subscriptions.Clear();
            DataCaptures.Clear();

            Sessions.AddRange(config.Sessions);
            Connections.AddRange(config.Connections);
            Subscriptions.AddRange(config.Subscriptions);
            SavedMessages.AddRange(config.SavedMessages);
            DataCaptures.AddRange(config.DataCaptures);
        }
예제 #2
0
        public void Read()
        {
            ConnectionStreamResponse r = new ConnectionStreamResponse()
            {
                NextStart = 0
            };

            while (!r.EndOfConnections)
            {
                r = RequestConnectionStream(r.NextStart);
                if (r == null || !(String.IsNullOrEmpty(r.Error)))
                {
                    //return on error
                    return;
                }
                else
                {
                    Connections.AddRange(r.ConnectionEntries);
                }

                if (!r.EndOfConnections)
                {
                    Thread.Sleep(CrawlUtil.GetVariableDelay(DelayBetweenAPIRequests));
                }
            }
        }
예제 #3
0
 public NetworkViewModel(int taskNumber, NetworkType type,
                         int numberOfStates, int numberOfInputs, int numberOfOutputs,
                         ICollection <NodeViewModel> nodes, ICollection <ConnectionViewModel> connections)
     : this(taskNumber, type, numberOfStates, numberOfInputs, numberOfOutputs)
 {
     Nodes.AddRange(nodes);
     Connections.AddRange(connections);
 }
예제 #4
0
        public void StartStreaming()
        {
            if (Started)
            {
                return;
            }

            LogTo.Info("Start realtime streaming on connection");
            Started       = true;
            StreamingTask = Stream.Start(c => Task.Run(() => ParseContent(c)))
                            .ContinueWith(t => Connections.AddRange(t.Result));
        }
 public void SetState(bool b)
 {
     if (b)
     {
         Connections.AddRange(temp);
     }
     else
     {
         temp = Connections;
         Connections.Clear();
     }
 }
예제 #6
0
        public ComlinkNode(NodeType nodeType, UniqueId id, float x, float y, uint color, string name, IEnumerable <IInputPin> inputPins, IEnumerable <IOutputPin> outputPins,
                           IEnumerable <Connection> connections) : this(nodeType, id)
        {
            X     = x;
            Y     = y;
            Color = color;
            Name  = name;

            InputPins.AddRange(inputPins);
            OutputPins.AddRange(outputPins);
            Connections.AddRange(connections);
        }
예제 #7
0
        internal override void SettingsUpdated()
        {
            base.SettingsUpdated();

            SquaresX     = Parent.SettingContainer.Settings.CalibrationSettings.ChArucoCalibrationSettings.SquaresX;
            SquaresY     = Parent.SettingContainer.Settings.CalibrationSettings.ChArucoCalibrationSettings.SquaresY;
            MarkerLength = Parent.SettingContainer.Settings.CalibrationSettings.ChArucoCalibrationSettings.MarkerLength;
            SquareLength = Parent.SettingContainer.Settings.CalibrationSettings.ChArucoCalibrationSettings.SquareLength;
            Dictionary   = Parent.SettingContainer.Settings.CalibrationSettings.ChArucoCalibrationSettings.Dictionary;

            TagSize          = Parent.SettingContainer.Settings.CalibrationSettings.AprilGridCalibration.TagSize;
            TagSpacingFactor = Parent.SettingContainer.Settings.CalibrationSettings.AprilGridCalibration.TagSpacingFactor;
            TagsX            = Parent.SettingContainer.Settings.CalibrationSettings.AprilGridCalibration.TagsX;
            TagsY            = Parent.SettingContainer.Settings.CalibrationSettings.AprilGridCalibration.TagsY;

            SelectedHost = Parent.SettingContainer.Settings.ConnectionSettings.SelectedConnection;

            AccelerometerScale = Parent.SettingContainer.Settings.ImuSettings.AccelerometerScale;
            GyroscopeScale     = Parent.SettingContainer.Settings.ImuSettings.GyroscopeScale;
            TemperatureScale   = Parent.SettingContainer.Settings.ImuSettings.TemperatureScale;
            TemperatureOffset  = Parent.SettingContainer.Settings.ImuSettings.TemperatureOffset;

            var firstNotSecondFile = FileLocations.Except(Parent.SettingContainer.Settings.GeneralSettings.FileLocations).ToList();
            var secondNotFirstFile = Parent.SettingContainer.Settings.GeneralSettings.FileLocations.Except(FileLocations).ToList();

            bool changed = firstNotSecondFile.Any() || secondNotFirstFile.Any();

            if (changed)
            {
                List <FileLocation> l = Parent.SettingContainer.Settings.GeneralSettings.FileLocations.ToList();
                FileLocations.Clear();
                FileLocations.AddRange(l);
            }

            var firstNotSecondCon = Connections.Except(Parent.SettingContainer.Settings.ConnectionSettings.Connections).ToList();
            var secondNotFirstCon = Parent.SettingContainer.Settings.ConnectionSettings.Connections.Except(Connections).ToList();

            changed = firstNotSecondCon.Any() || secondNotFirstCon.Any();

            if (changed)
            {
                List <Connection> l = Parent.SettingContainer.Settings.ConnectionSettings.Connections.ToList();
                Connections.Clear();
                Connections.AddRange(l);
            }
        }
예제 #8
0
 /// <summary>
 /// Replaces the connections and rebuilds the tree.
 /// </summary>
 /// <param name="connections">The connections.</param>
 /// <remarks>Documented by Dev03, 2009-03-20</remarks>
 public void ReplaceConnections(List <IConnectionString> connections)
 {
     if (Connections.Count == 0)
     {
         Connections.AddRange(connections);
     }
     else
     {
         Folders.ListChanged     -= new EventHandler <ObservableListChangedEventArgs <FolderIndexEntry> >(Folders_ListChanged);
         Connections.ListChanged -= new EventHandler <ObservableListChangedEventArgs <IConnectionString> >(Connections_ListChanged);
         mainNode.Nodes.Clear();
         Folders.Clear();
         Connections.Clear();
         Folders.ListChanged     += new EventHandler <ObservableListChangedEventArgs <FolderIndexEntry> >(Folders_ListChanged);
         Connections.ListChanged += new EventHandler <ObservableListChangedEventArgs <IConnectionString> >(Connections_ListChanged);
         Connections.AddRange(connections);
     }
 }
예제 #9
0
 public static IEventStream <T> MergeCollectionOfStreams <T>(this IReactiveCollection <IEventStream <T> > collection)
 {
     return(new AnonymousEventStream <T>(action =>
     {
         var connections = new Connections();
         var disposable = new DoubleDisposable
         {
             First = connections,
         };
         disposable.Second =
             // TODO It can be done more effectively then asCell call but much more complex
             collection.AsCell().Bind(coll =>
         {
             connections.DisconnectAll();
             if (disposable.disposed)
             {
                 return;
             }
             connections.AddRange(coll.Select(item => item.Subscribe(action)));
         });
         return disposable;
     }));
 }
예제 #10
0
        private void InsertConnections(Connection[] connections, Connection selected, bool force = false)
        {
            var names = connections.Select(x => x.Name).ToArray();

            var list = Connections
                       .Skip(1)
                       .Take(Connections.Count - 2)
                       .Where(x => !names.Contains(x.Name))
                       .Concat(connections)
                       .OrderBy(x => x.Name)
                       .ToList();

            if (Connections.Any() || force)
            {
                SaveConnectionsToFile(list);
            }

            Connections.Clear();
            Connections.Add(_selectConnectionItem);
            Connections.AddRange(list);
            Connections.Add(_addNewConnectionItem);
            Connection = selected;
        }
예제 #11
0
        private void OnConnectionUpdate(ConnectionStatus lastStatus, NetConnection senderConnection)
        {
            Connections.Clear();

            switch (_config.SysType)
            {
            case SysType.Peer:
                break;

            case SysType.Client:
                break;

            case SysType.Server:
                if (_netServer == null)
                {
                    break;
                }

                Connections.AddRange(
                    _netServer.Connections.Select(
                        connection => new NetworkConnection {
                    Connection = connection, NetworkImp = this
                }));

                break;
            }

            // event OnConnectionUpdate
            var newConnection = new NetworkConnection {
                Connection = senderConnection, NetworkImp = this
            };

            if (ConnectionUpdate != null)
            {
                ConnectionUpdate(lastStatus, newConnection);
            }
        }