Пример #1
0
        public void OnImageCaptured(HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.IFrameSource frameSource, 
                                    HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.Frame frame, double fps)
        {
            List<VParamType> ret = new List<VParamType>();

            lock (this)
            {
                _latestFrame = frame.Image;

                var newImageBytes = ImageToByteArray(frame.Image);

                //make a copy, so we do not pass on this new object to the remote guys (which leads to higher memory consumption)

                if (_latestImageBytes.Length < newImageBytes.Length)
                {
                    _latestImageBytes = newImageBytes;
                }
                else
                {
                    Buffer.BlockCopy(newImageBytes, 0, _latestImageBytes, 0, newImageBytes.Length);
                }
            }

            ret.Add(new ParamType(ParamType.SimpleType.jpegimage, _latestImageBytes));

            cameraPort.Notify(RoleCamera.RoleName, RoleCamera.OpGetVideo, ret);
        }
Пример #2
0
        public bool IsCompatibleWithRole(HomeOS.Hub.Platform.Views.VRole role)
        {
            foreach (RoleList roleList in roleLists)
            {
                if (roleList.IsContained(role))
                    return true;
            }

            return false;
        }
Пример #3
0
        public bool IsContained(HomeOS.Hub.Platform.Views.VRole role)
        {
            foreach (HomeOS.Hub.Platform.Views.VRole myRole in roles)
            {
                if (Role.ContainsRole(role, myRole))
                    return true;
            }

            return false;
        }
Пример #4
0
        internal static VModuleState C2V(HomeOS.Hub.Platform.Contracts.IModuleState contract)
        {
            if (contract == null)
                return null;

            if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) &&
                (contract.GetType().Equals(typeof(ModuleStateV2C))))
            {
                return ((ModuleStateV2C)(contract)).GetSourceView();
            }
            else
            {
                return new ModuleStateC2V(contract);
            }
        }
Пример #5
0
        public PortInfo(HomeOS.Hub.Platform.Views.VModuleInfo moduleInfo, string moduleFacingName, 
                        List<HomeOS.Hub.Platform.Views.VRole> roles, string friendlyName)
        {
            this.friendlyName = friendlyName;
            this.moduleInfo = moduleInfo;
            this.moduleFacingName = moduleFacingName;

            if (roles != null)
            {
                this.roles = roles;
            }
            else
            {
                this.roles = new List<HomeOS.Hub.Platform.Views.VRole>();
            }
        }
Пример #6
0
        //***
        /// <summary>
        /// Does this location contain this port?
        /// </summary>
        public bool ContainsPort(HomeOS.Hub.Platform.Views.VPortInfo portInfo)
        {
            foreach (var childPort in ChildPorts)
            {
                if (childPort.Equals(portInfo))
                    return true;
            }

            foreach (var childLocation in ChildLocations)
            {
                if (childLocation.ContainsPort(portInfo))
                    return true;
            }

            return false;
        }
        private void NewFrame(HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.IFrameSource frameSource, HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.Frame frame, double fps)
        {
            //We want to ignore frames we can't render fast enough
            lock (_frameSync)
            {
                if (!_frameWaiting)
                {
                    _frameWaiting = true;
                    Action workAction = delegate
                    {
                        this.labelCameraFPSValue.Content = fps.ToString();
                        this.imgPreview.Source = frame.OriginalImage.ToBitmapSource();

                        lock (_frameSync)
                        {
                            _frameWaiting = false;
                        }
                    };
                    Dispatcher.BeginInvoke(workAction);
                }
            }
        }
Пример #8
0
        ///unclear how to make this safe
        public SafeThread(ThreadStart start, string name, HomeOS.Hub.Platform.Views.VLogger logger)
        {
            this.logger = logger;
            thread = new Thread(delegate()
            {
                try
                {
                    start();
                }
                catch (Exception exception)
                {
                    //string message = "HomeOS SafeThread named: " + name + ", raised exception: " + exception.GetType();
                    string message = "HomeOS SafeThread named: " + name + ", raised exception: " + exception.ToString();
                    logger.Log(message);

                    //lets print these messages to stderr as well
                    Console.Error.WriteLine(message);
                }
            }
                    );
            thread.Name = name;
        }
Пример #9
0
 public override void Update(HomeOS.Hub.Platform.Views.VModuleState s)
 {
     this.state = (SimpleState)s.GetSimpleState();
     this.timestamp = s.GetTimestamp();
 }
Пример #10
0
 public void PortRegistered(HomeOS.Hub.Platform.Contracts.IPort port)
 {
     _view.PortRegisteredWithHooks(PortAdapter.C2V(port));
 }
Пример #11
0
 //***
 public int InstallCapability(HomeOS.Hub.Platform.Contracts.ICapability capability, HomeOS.Hub.Platform.Contracts.IPort targetPort)
 {
     return _view.InstallCapability(CapabilityAdapter.C2V(capability), PortAdapter.C2V(targetPort));
 }
Пример #12
0
 public void OnImageCaptured(HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.IFrameSource frameSource, HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.Frame frame, double fps)
 {
     _latestFrame = frame.Image;
     pictureBoxDisplay.Invalidate();
 }
Пример #13
0
 public void AddRole(HomeOS.Hub.Platform.Views.VRole role)
 {
     roles.Add(role);
 }
Пример #14
0
 public void CancelAllSubscriptions(HomeOS.Hub.Platform.Contracts.IModule module , HomeOS.Hub.Platform.Contracts.IPort controlPort, HomeOS.Hub.Platform.Contracts.ICapability controlportcap)
 {
     _view.CancelAllSubscriptions( ModuleAdapter.C2V(module), PortAdapter.C2V(controlPort), CapabilityAdapter.C2V(controlportcap));
 }
Пример #15
0
 public ModuleStateC2V(HomeOS.Hub.Platform.Contracts.IModuleState contract)
 {
     _contract = contract;
     _handle = new ContractHandle(contract);
 }
Пример #16
0
 public PortInfo(string moduleFacingName, HomeOS.Hub.Platform.Views.VModuleInfo moduleInfo, 
                 List<HomeOS.Hub.Platform.Views.VRole> roles)
     : this(moduleInfo, moduleFacingName, roles, null)
 {
 }
Пример #17
0
 public PortInfo(string moduleFacingName, HomeOS.Hub.Platform.Views.VModuleInfo moduleInfo)
     : this(moduleInfo, moduleFacingName, null, null)
 {
 }
Пример #18
0
 /// <summary>
 /// Handler for end-of-forwarding event.
 /// </summary>
 /// <param name="forwarder">The forwarder that is closing.</param>
 private void StopForwarding(HomeOS.Shared.Gatekeeper.Forwarder forwarder)
 {
 }
Пример #19
0
 public HomeOS.Hub.Platform.Contracts.IPortInfo GetPortInfo(string moduleFacingName, HomeOS.Hub.Platform.Contracts.IModule module)
 {
     return PortInfoAdapter.V2C(_view.GetPortInfo(moduleFacingName, ModuleAdapter.C2V(module)));
 }
Пример #20
0
 public void Update(HomeOS.Hub.Platform.Contracts.IModuleState s)
 {
     _view.Update(ModuleStateAdapter.C2V(s));
 }
Пример #21
0
 public void SetLocation(HomeOS.Hub.Platform.Views.VLocation location)
 {
     this.location = location;
 }
Пример #22
0
 public int DeregisterPort(HomeOS.Hub.Platform.Contracts.IPort port, HomeOS.Hub.Platform.Contracts.IModule module)
 {
     return _view.DeregisterPort(PortAdapter.C2V(port), ModuleAdapter.C2V(module));
 }
Пример #23
0
 internal static bool Expired(HomeOS.Hub.Platform.Views.VCapability capability)
 {
     return capability.ExpiryTime() < DateTime.Now;
 }
Пример #24
0
 //***
 public void UpdateState(HomeOS.Hub.Platform.Contracts.IModule module, HomeOS.Hub.Platform.Contracts.IModuleState state)
 {
      _view.UpdateState(ModuleAdapter.C2V(module), ModuleStateAdapter.C2V(state));
 }