Example #1
0
        /// <summary>
        /// Public method called by the osc server, to process osc event messages.
        /// </summary>
        /// <param name="zoneAddress">Zone address</param>
        /// <param name="oscEvent">Osc event</param>
        public void processOscNuvoEventForClients(Address zoneAddress, OscEvent oscEvent)
        {
            // forward message to client
            _oscDriver.SendMessage(oscEvent);
            // forward (debug) message to client
            _oscDriver.SendMessage("/NuvoControl/message", String.Format("Notify {0}: {1}", _oscDeviceId, oscEvent.ToString()));

            if (oscEvent.OscLabel.Contains("/Generic"))
            {
                if (oscEvent.OscLabel.Contains("/ZoneSelection"))
                {
                    if (oscEvent.getOscData == 0)
                    {
                        // ignore message with value 0, as this is only the "disable" message for the previous selected source
                    }
                    else if (oscEvent.getOscData == 1)
                    {
                        _genericZoneId = oscEvent.getZoneId;
                        _oscDriver.SendMessage(String.Format("/NuvoControl/Generic/ZoneName"), _zones[zoneAddress].Name);
                        _oscDriver.SendMessage("/NuvoControl/message", String.Format("Zone '{0}' selected", _zones[zoneAddress].Name));

                        // update generic items with zone status of selected zone
                        Address genericZoneAddress = new Address(zoneAddress.DeviceId, _genericZoneId);
                        UpdateZoneStateOnOscClient(genericZoneAddress, _zoneStateList[genericZoneAddress]);
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Send an osc message to the client.
 /// </summary>
 /// <param name="oscEvent">Osc event to send (incl. message and values).</param>
 public void SendMessage(OscEvent oscEvent)
 {
     if ((_oscDevice != null) && (_oscDevice.DeviceType == eOSCDeviceType.OSCClient) && (_oscDevice.SendPort > -1))
     {
         sendOscMessage(oscEvent.OscLabel, oscEvent.OscData, _oscDevice.IpAddress, _oscDevice.SendPort);
     }
 }
Example #3
0
        private void oscServer_MessageReceived(object sender, OscMessageReceivedEventArgs e)
        {
            sMessagesReceivedCount++;
            LogHelper.Log(LogLevel.Info, string.Format("[OSC] Msg Rcv [{0}]: {1} / Message contains {2} objects. [{3}]", e.Message.SourceEndPoint.Address, e.Message.Address, e.Message.Data.Count, sMessagesReceivedCount));
            for (int i = 0; i < e.Message.Data.Count; i++)
            {
                LogHelper.Log(LogLevel.Debug, string.Format("[OSC] {0}: Value={1}", i, convertDataString(e.Message.Data[i])));
            }

            OscEvent oscEvent = processTouchOscMessageForNuvoControl(e.Message);

            if (oscEvent != null)
            {
                LogHelper.Log(LogLevel.Info, string.Format("[OSC] NuvoControl OscEvent={0}", oscEvent.ToString()));
                //raise the event, and pass data to next layer
                if (onOscNuvoEventReceived != null)
                {
                    onOscNuvoEventReceived(this, new OscEventReceivedEventArgs(_oscDevice.DeviceId, oscEvent, e.Message.SourceEndPoint));
                }
                if (onOscEventReceived != null)
                {
                    onOscEventReceived(this, new OscEventReceivedEventArgs(_oscDevice.DeviceId, oscEvent, e.Message.SourceEndPoint));
                }
            }
            else
            {
                oscEvent = processTouchOscMessageFromDefaultLayouts(e.Message);
                if (oscEvent != null)
                {
                    LogHelper.Log(LogLevel.Info, string.Format("[OSC] OscEvent={0}", oscEvent.ToString()));
                    //raise the event, and pass data to next layer
                    if (onOscEventReceived != null)
                    {
                        onOscEventReceived(this, new OscEventReceivedEventArgs(_oscDevice.DeviceId, oscEvent, e.Message.SourceEndPoint));
                    }
                }
                else
                {
                    LogHelper.Log(LogLevel.Warn, string.Format("[OSC] Unknown message: {0}", e.Message.Address));
                }
            }
        }
Example #4
0
 /// <summary>
 /// Private method which handles the osc messages for the server.
 /// </summary>
 /// <param name="zoneAddress">Zone Address.</param>
 /// <param name="oscEvent">Osc event.</param>
 private void processOscNuvoEventAsServer(Address zoneAddress, OscEvent oscEvent)
 {
     if (oscEvent.OscCommand == eOscEvent.NuvoControl)
     {
         if (oscEvent.OscLabel.Contains("/Status"))
         {
             if (oscEvent.getOscData == 0)
             {
                 _protocolDriver.CommandSwitchZoneOFF(zoneAddress);
             }
             else if (oscEvent.getOscData == 1)
             {
                 _protocolDriver.CommandSwitchZoneON(zoneAddress);
             }
             else
             {
                 // Trace error, received an unkown status
             }
         }
         else if (oscEvent.OscLabel.Contains("/SourceSelection"))
         {
             if (oscEvent.getOscData == 0)
             {
                 // ignore message with value 0, as this is only the "disable" message for the previous selected source
             }
             else if (oscEvent.getOscData == 1)
             {
                 _protocolDriver.CommandSetSource(zoneAddress, new Address(zoneAddress.DeviceId, oscEvent.getSourceId));
             }
             else
             {
                 // Trace error, received an unkown source command
             }
         }
         else if (oscEvent.OscLabel.Contains("/VolumeUp"))
         {
             if (oscEvent.getOscData == 0)
             {
                 _protocolDriver.CommandStopRampVolume(zoneAddress);
             }
             else if (oscEvent.getOscData == 1)
             {
                 _protocolDriver.CommandRampVolumeUP(zoneAddress);
             }
             else
             {
                 // Trace error, received an unkown source command
             }
         }
         else if (oscEvent.OscLabel.Contains("/VolumeDown"))
         {
             if (oscEvent.getOscData == 0)
             {
                 _protocolDriver.CommandStopRampVolume(zoneAddress);
             }
             else if (oscEvent.getOscData == 1)
             {
                 _protocolDriver.CommandRampVolumeDOWN(zoneAddress);
             }
             else
             {
                 // Trace error, received an unkown source command
             }
         }
         else if (oscEvent.OscLabel.Contains("/Volume"))
         {
             _protocolDriver.CommandSetVolume(zoneAddress, oscEvent.getOscData);
         }
         else if (oscEvent.OscLabel.Contains("/Mute"))
         {
             if (oscEvent.getOscData == 0)
             {
                 _protocolDriver.CommandMuteOFF(zoneAddress);
             }
             else if (oscEvent.getOscData == 1)
             {
                 _protocolDriver.CommandMuteON(zoneAddress);
             }
             else
             {
                 // Trace error, received an unkown status
             }
         }
         else if (oscEvent.OscLabel.Contains("/KeyPadLock"))
         {
             if (oscEvent.getOscData == 0)
             {
                 _protocolDriver.CommandSetKeypadLockOFF(zoneAddress);
             }
             else if (oscEvent.getOscData == 1)
             {
                 _protocolDriver.CommandSetKeypadLockON(zoneAddress);
             }
             else
             {
                 // Trace error, received an unkown status
             }
         }
         else if (oscEvent.OscLabel.Contains("/Bass"))
         {
             _protocolDriver.CommandSetBassLevel(zoneAddress, oscEvent.getOscData);
         }
         else if (oscEvent.OscLabel.Contains("/Treble"))
         {
             _protocolDriver.CommandSetTrebleLevel(zoneAddress, oscEvent.getOscData);
         }
     }
 }
Example #5
0
 public void UnRegisterMethod(OscEvent oscEvent)
 {
     throw new NotImplementedException();
 }