Exemplo n.º 1
0
        void LoadChannel(ChannelDescription chan, SourcesArgs args, string proftoken = null)
        {
            //Create channel control
            DeviceChannelControl channControl = new DeviceChannelControl();

            //add control to controls dictionary
            channelControls.Add(chan.videoSource.token, channControl);

            //Display progress bar
            ShowLoadingProgress(channControl, chan.videoSource.token);

            //add control to parent UI panel
            parent.Children.Add(channControl);

            InitChannelControl(channControl, chan, args);

            //subscribe to profile changed event
            var subsToken = eventAggregator.GetEvent <ProfileChangedEvent>().Subscribe(evargs => {
                if (evargs.vsToken == chan.videoSource.token)
                {
                    //reload channel with new profile
                    InitChannelControl(channControl, chan, args, evargs.profToken);
                }
            }, false);

            disposables.Add(Disposable.Create(() => {
                eventAggregator.GetEvent <ProfileChangedEvent>().Unsubscribe(subsToken);
            }));
        }
Exemplo n.º 2
0
        private FamosFileChannel PrepareChannel(FamosFileField field, ChannelDescription channelDescription, int totalLength, DateTime startDateTme, double dx)
        {
            // component
            var datasetName = $"{channelDescription.ChannelName}_{channelDescription.DatasetName.Replace(" ", "_")}";
            var calibration = new FamosFileCalibration(false, 1, 0, false, channelDescription.Unit);

            var component = new FamosFileAnalogComponent(datasetName, FamosFileDataType.Float64, totalLength, calibration)
            {
                XAxisScaling = new FamosFileXAxisScaling((decimal)dx)
                {
                    Unit = "s"
                },
                TriggerTime = new FamosFileTriggerTime(startDateTme, FamosFileTimeMode.Unknown),
            };

            // attributes
            var channel = component.Channels.First();

            channel.PropertyInfo = new FamosFilePropertyInfo(new List <FamosFileProperty>()
            {
                new FamosFileProperty("name", channelDescription.ChannelName),
                new FamosFileProperty("group", channelDescription.Group),
                new FamosFileProperty("comment", "yyyy-MM-ddTHH-mm-ssZ: Comment1"),
            });

            field.Components.Add(component);

            return(channel);
        }
		void InitChannelControl(DeviceChannelControl channControl, ChannelDescription chan, SourcesArgs args, string proftoken = null) {
			//try to remove and clear all needed data
			if (channControl.Content is IDisposable) {
				var disp = channControl.Content as IDisposable;
				//try to remove content from disposables collection
				if(disposables.Contains(disp))
					disposables.Remove(disp);
				//dispose existing control
				disp.Dispose();
			}

			//Begin load channels section
			disposables.Add(SourceView.Load(chan, args.capabilities, args.nvtSession, args.odmSession, proftoken)
				.ObserveOnCurrentDispatcher()
				.Subscribe(sourceArgs => {
					if (sourceArgs.selectedProfile != null)
						channControl.Title = sourceArgs.channelDescr.videoSource.token + ": " + sourceArgs.selectedProfile.name;
					else
						channControl.Title = sourceArgs.channelDescr.videoSource.token;

					SourceView sourceView = new SourceView(container);
					disposables.Add(sourceView);

					sourceView.Init(sourceArgs);
					channControl.Content = sourceView;
				}, err => {
					ErrorView errorView = new ErrorView(err);
					disposables.Add(errorView);

					channControl.Content = errorView;
				}
			));
		}
Exemplo n.º 4
0
        /// <summary>
        /// Метод подписки на события журнала.
        /// </summary>
        /// <param name="filter">Фильтр событий.</param>
        /// <param name="channel">Канал передачи событий.</param>
        /// <param name="cookie">Идентификатор подписки.</param>
        void ISrvcBlackboard.Subscribe(IEventFilter filter, ChannelDescription channel, Guid cookie)
        {
            Logger.Debug("ISrvcBlackboard.Subscribe: подписался {0}", cookie);
            // создаем канал
            ISenderChannel ch = channel != null?UnitySingleton.Resolve <ITransport>().CreateSenderChannel(channel) : null;

            _subsribeTask.Run(() => (this as IBlackboard).Subscribe(filter, ch, cookie));
        }
		public static FSharpAsync<SourceViewArgs> Load(ChannelDescription channelDescr,
														Capabilities capabilities,
														INvtSession nvtSession,
														OdmSession odmsession,
														string prof = null) {
			SourceViewArgs args = new SourceViewArgs();
			args.nvtSession = nvtSession;
			args.odmSession = odmsession;
			args.capabilities = capabilities;
			args.channelDescr = channelDescr;
			args.selectedProfileToken = prof;

			return Apm.Iterate(LoadImpl(args)).Select(f => { return args; });
		}
Exemplo n.º 6
0
        public static FSharpAsync <SourceViewArgs> Load(ChannelDescription channelDescr,
                                                        Capabilities capabilities,
                                                        INvtSession nvtSession,
                                                        OdmSession odmsession,
                                                        string prof = null)
        {
            SourceViewArgs args = new SourceViewArgs();

            args.nvtSession           = nvtSession;
            args.odmSession           = odmsession;
            args.capabilities         = capabilities;
            args.channelDescr         = channelDescr;
            args.selectedProfileToken = prof;

            return(Apm.Iterate(LoadImpl(args)).Select(f => { return args; }));
        }
Exemplo n.º 7
0
        void InitChannelControl(DeviceChannelControl channControl, ChannelDescription chan, SourcesArgs args, string proftoken = null)
        {
            //try to remove and clear all needed data
            if (channControl.Content is IDisposable)
            {
                var disp = channControl.Content as IDisposable;
                //try to remove content from disposables collection
                if (disposables.Contains(disp))
                {
                    disposables.Remove(disp);
                }
                //dispose existing control
                disp.Dispose();
            }

            //Begin load channels section
            disposables.Add(SourceView.Load(chan, args.capabilities, args.nvtSession, args.odmSession, proftoken)
                            .ObserveOnCurrentDispatcher()
                            .Subscribe(sourceArgs => {
                if (sourceArgs.selectedProfile != null)
                {
                    channControl.Title = sourceArgs.channelDescr.videoSource.token + ": " + sourceArgs.selectedProfile.name;
                }
                else
                {
                    channControl.Title = sourceArgs.channelDescr.videoSource.token;
                }

                SourceView sourceView = new SourceView(container);
                disposables.Add(sourceView);

                sourceView.Init(sourceArgs);
                channControl.Content = sourceView;
            }, err => {
                ErrorView errorView = new ErrorView(err);
                disposables.Add(errorView);

                channControl.Content = errorView;
            }
                                       ));
        }
 public static void Serialize(Stream stream, ChannelInvitation instance)
 {
     if (instance.ChannelDescription == null)
     {
         throw new ArgumentNullException("ChannelDescription", "Required by proto specification.");
     }
     stream.WriteByte(10);
     ProtocolParser.WriteUInt32(stream, instance.ChannelDescription.GetSerializedSize());
     ChannelDescription.Serialize(stream, instance.ChannelDescription);
     if (instance.HasReserved)
     {
         stream.WriteByte(16);
         ProtocolParser.WriteBool(stream, instance.Reserved);
     }
     if (instance.HasRejoin)
     {
         stream.WriteByte(24);
         ProtocolParser.WriteBool(stream, instance.Rejoin);
     }
     stream.WriteByte(32);
     ProtocolParser.WriteUInt32(stream, instance.ServiceType);
 }
Exemplo n.º 9
0
        public ChannelViewModel(INvtSession session, ChannelDescription channelDescr, IUnityContainer container, Capabilities devcap)
        {
            this.eventAggregator = container.Resolve <IEventAggregator>();
            this.devcap          = devcap;
            UIsubscription       = eventAggregator.GetEvent <VideoChangedEvent>().Subscribe(VideoChangedEvent, false);
            RefreshSubscription  = eventAggregator.GetEvent <RefreshSelection>().Subscribe(RefreshSelection, false);
            ProfileSubscription  = eventAggregator.GetEvent <ProfileChangedEvent>().Subscribe(ProfileChangedEvent, false);
            this.videoSource     = channelDescr.videoSource;
            this.session         = session;
            this.container       = container;
            Buttons = new ObservableCollection <ButtonBase>();
            Name    = InfoStrings.loadingData;

            SnapShotClick = new DelegateCommand(() => {
                if (profToken != null)
                {
                    GetSnapshot(profToken);
                }
            });

            BindData();
            Load();
        }
		void LoadChannel(ChannelDescription chan, SourcesArgs args, string proftoken = null) {
			//Create channel control
			DeviceChannelControl channControl = new DeviceChannelControl();
			//add control to controls dictionary
			channelControls.Add(chan.videoSource.token, channControl);
			
			//Display progress bar
			ShowLoadingProgress(channControl, chan.videoSource.token);

			//add control to parent UI panel
			parent.Children.Add(channControl);

			InitChannelControl(channControl, chan, args);

			//subscribe to profile changed event
			var subsToken = eventAggregator.GetEvent<ProfileChangedEvent>().Subscribe(evargs => {
				if (evargs.vsToken == chan.videoSource.token) {
					//reload channel with new profile
					InitChannelControl(channControl, chan, args, evargs.profToken);
				}
			}, false);
			disposables.Add(Disposable.Create(() => {
				eventAggregator.GetEvent<ProfileChangedEvent>().Unsubscribe(subsToken);
			}));
		}
 public static ChannelInvitation Deserialize(Stream stream, ChannelInvitation instance, long limit)
 {
     instance.Reserved = false;
     instance.Rejoin   = false;
     while (limit < 0L || stream.get_Position() < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else
         {
             int num2 = num;
             if (num2 != 10)
             {
                 if (num2 != 16)
                 {
                     if (num2 != 24)
                     {
                         if (num2 != 32)
                         {
                             Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                             uint field = key.Field;
                             if (field == 0u)
                             {
                                 throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                             }
                             ProtocolParser.SkipKey(stream, key);
                         }
                         else
                         {
                             instance.ServiceType = ProtocolParser.ReadUInt32(stream);
                         }
                     }
                     else
                     {
                         instance.Rejoin = ProtocolParser.ReadBool(stream);
                     }
                 }
                 else
                 {
                     instance.Reserved = ProtocolParser.ReadBool(stream);
                 }
             }
             else if (instance.ChannelDescription == null)
             {
                 instance.ChannelDescription = ChannelDescription.DeserializeLengthDelimited(stream);
             }
             else
             {
                 ChannelDescription.DeserializeLengthDelimited(stream, instance.ChannelDescription);
             }
         }
     }
     if (stream.get_Position() == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
 public void SetChannelDescription(ChannelDescription val)
 {
     this.ChannelDescription = val;
 }