Beispiel #1
0
 public TouchOscDriver(OSCDevice oscDevice)
 {
     _oscDevice = oscDevice;
     if (_oscDevice.DeviceType == eOSCDeviceType.OSCServer)
     {
         _oscServer = new OscServer(TransportType.Udp, oscDevice.IpAddress, oscDevice.ListenPort, true, false);
     }
     else if (_oscDevice.DeviceType == eOSCDeviceType.OSCClient)
     {
     }
 }
Beispiel #2
0
 public void Stop()
 {
     if (_oscDevice.DeviceType == eOSCDeviceType.OSCServer && _oscServer != null)
     {
         _oscServer.Stop();
         _oscDevice = null;
     }
     else if (_oscDevice.DeviceType == eOSCDeviceType.OSCClient)
     {
         sendDebugMessage(String.Format("Server stopped, disconnect from {0} ...", _oscDevice.Name), _oscDevice.IpAddress, _oscDevice.SendPort);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="oscDeviceId">The Id of this osc device.</param>
        /// <param name="oscDevice">The osc device configuration of this osc device.</param>
        /// <param name="protocolDriver">The associated protocol driver to command the device (NuvoEssentia) of the zone</param>
        /// <param name="oscDriver">The associated osc driver to command the osc device.</param>
        public OscDeviceController(Address oscDeviceId, OSCDevice oscDevice, IProtocol protocolDriver, IOscDriver oscDriver, Dictionary <Address, Zone> zones, List <Source> sources)
        {
            this._oscDeviceId    = oscDeviceId;
            this._oscDevice      = oscDevice;
            this._protocolDriver = protocolDriver;
            this._protocolDriver.onZoneStatusUpdate   += new ProtocolZoneUpdatedEventHandler(_protocolDriver_onZoneStatusUpdate);
            this._protocolDriver.onDeviceStatusUpdate += new ProtocolDeviceUpdatedEventHandler(_protocolDriver_onDeviceStatusUpdate);
            this._oscDriver = oscDriver;
            this._oscDriver.onOscNuvoEventReceived += new OscEventReceivedEventHandler(_oscDriver_onOscNuvoEventReceived);
            this._zones   = zones;
            this._sources = sources;

            // Init "static" text (configuration data)
            updateConfigurationDataOnOscClient();
        }
Beispiel #4
0
        /// <summary>
        /// Copy Constructor
        /// </summary>
        /// <param name="oscDeviceId">The Id of this osc device.</param>
        /// <param name="oscDevice">The osc device configuration of this osc device.</param>
        /// <param name="oscDeviceController">Controller to copy.</param>
        public OscDeviceController(Address oscDeviceId, OSCDevice oscDevice, OscDeviceController oscDeviceController)
        {
            this._oscDeviceId    = oscDeviceId;
            this._oscDevice      = oscDevice;
            this._protocolDriver = oscDeviceController._protocolDriver;
            this._protocolDriver.onZoneStatusUpdate   += new ProtocolZoneUpdatedEventHandler(_protocolDriver_onZoneStatusUpdate);
            this._protocolDriver.onDeviceStatusUpdate += new ProtocolDeviceUpdatedEventHandler(_protocolDriver_onDeviceStatusUpdate);
            this._oscDriver = new TouchOscDriver(oscDevice);
            this._oscDriver.onOscNuvoEventReceived += new OscEventReceivedEventHandler(_oscDriver_onOscNuvoEventReceived);
            this._zones   = oscDeviceController._zones;
            this._sources = oscDeviceController._sources;

            // Init "static" text (configuration data)
            updateConfigurationDataOnOscClient();
        }
Beispiel #5
0
        /// <summary>
        /// Event method, to receive nuvo control messages from osc devices.
        /// This method sends updates to all connected clients.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OscServer_onOscNuvoEventReceived(object sender, ProtocolDriver.Interface.OscEventReceivedEventArgs e)
        {
            sNuvoMessagesReceivedCount++;
            _log.Trace(m => m("OSCS: Device (id={0}) nuvo control event ({1}) from {2}: {3}", e.OscDevice, sNuvoMessagesReceivedCount, e.SourceEndPoint, e.OscEvent.ToString()));
            _oscDeviceLastUpdate[e.SourceEndPoint.Address] = DateTime.Now;

            bool bKnown = false;

            foreach (OscDeviceController oscDeviceController in _oscDeviceControllers.Values)
            {
                // forward message to clients
                oscDeviceController.processOscNuvoEventForClients(new Address(e.OscDeviceId, e.OscEvent.getZoneId), e.OscEvent);
                // forward (debug) message to clients
                //oscDeviceController.GetOscDriver().SendMessage("/NuvoControl/message", String.Format("Notify {0}/{1}: {2}", sMessagesReceivedCount, oscDeviceController.OscDeviceId, e.OscEvent.ToString()));
                // Check if client is "known"
                if (String.Compare(oscDeviceController.OscDevice.IpAddress.ToString(), e.SourceEndPoint.Address.ToString()) == 0)
                {
                    bKnown = true;
                }
            }

            // If client was/is not known ...
            if (!bKnown)
            {
                // ... create "ad-hoc" controller, to start updating this client, assuming the client listen to port 9000
                _log.Trace(m => m("OSCS.onOscNuvoEventReceived: Client {0} not known, add with id={1}!", e.SourceEndPoint, adhocDeviceIdCounter));
                lock (_oscDeviceControllers)
                {
                    Address             address   = new Address(e.OscDeviceId, adhocDeviceIdCounter);
                    OSCDevice           oscDevice = new OSCDevice(address, eOSCDeviceType.OSCClient, address, String.Format("AdHocClient{0}", adhocDeviceIdCounter), e.SourceEndPoint.Address, 8000, 9000, null);
                    OscDeviceController adhocOscDeviceController = new OscDeviceController(address, oscDevice, _oscDeviceControllers[e.OscDevice]);
                    _oscDeviceControllers.Add(address, adhocOscDeviceController);
                    adhocDeviceIdCounter--;
                }
            }
        }