Exemple #1
0
        internal ActiveCNXConnection(int IPID, string IPAddress, int IPPort, string UserName, string Password, bool UseSSL, VLogger logger)
        {
            this.logger    = logger;
            this.IPID      = IPID;
            this.IPAddress = IPAddress;
            this.IPPort    = IPPort;
            this.UserName  = UserName;
            this.Password  = Password;
            this.UseSSL    = UseSSL;

            this.acnxConnection = new ActiveCNX();


            // Define event handlers for the various events that are generated by ActiveCNX.NET
            this.acnxConnection.onConnect    += new Crestron.ActiveCNX.ActiveCNXConnectionEventHandler(acnxConnection_onConnect);
            this.acnxConnection.onDisconnect += new Crestron.ActiveCNX.ActiveCNXConnectionEventHandler(acnxConnection_onDisconnect);
            this.acnxConnection.onError      += new Crestron.ActiveCNX.ActiveCNXErrorEventHandler(acnxConnection_onError);
            this.acnxConnection.onDigital    += new Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onDigital);

            /*	  this.acnxConnection.onAnalog +=new Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onAnalog);
             *
             * this.acnxConnection.onSerial += new Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onSerial);
             * this.acnxConnection.onCertVerification += new Crestron.ActiveCNX.ActiveCNXCertificateEventHandler(acnxConnection_onCertVerification);
             * */
        }
 public CrestronRoomActivityViewModel(CrestronRoom room)
 {
     Device               = new ActiveCNX(room.IpAddress, room.IpId, room.UserName, room.Password, room.Port, room.UseSsl);
     Device.onAnalog     += Device_onAnalog;
     Device.onConnect    += Device_onConnect;
     Device.onDigital    += Device_onDigital;
     Device.onDisconnect += Device_onDisconnect;
     Device.onError      += Device_onError;
     Messages             = new ObservableRangeCollection <ActivityMessage>();
     Title = room.Name;
 }
Exemple #3
0
        internal ActiveCNXConnection(DigitalMediaPanelDescription connectionDescription, VLogger logger)
        {
            this.logger         = logger;
            this.acnxConnection = new ActiveCNX();

            // Define event handlers for the various events that are generated by ActiveCNX.NET
            this.acnxConnection.onConnect    += new Crestron.ActiveCNX.ActiveCNXConnectionEventHandler(acnxConnection_onConnect);
            this.acnxConnection.onDisconnect += new Crestron.ActiveCNX.ActiveCNXConnectionEventHandler(acnxConnection_onDisconnect);
            this.acnxConnection.onError      += new Crestron.ActiveCNX.ActiveCNXErrorEventHandler(acnxConnection_onError);

            /*	  this.acnxConnection.onAnalog +=new Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onAnalog);
             * this.acnxConnection.onDigital += new Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onDigital);
             * this.acnxConnection.onSerial += new Crestron.ActiveCNX.ActiveCNXEventHandler(acnxConnection_onSerial);
             * this.acnxConnection.onCertVerification += new Crestron.ActiveCNX.ActiveCNXCertificateEventHandler(acnxConnection_onCertVerification);
             * */
            if ((connectionDescription.IPAddress != null) && (connectionDescription.IPPort > 0))
            {
                /*  this.acnxConnection.Connect(connectionDescription.IPAddress,
                 *    connectionDescription.IPID, connectionDescription.UserName, connectionDescription.Password,
                 *    connectionDescription.IPPort, connectionDescription.UseSSL, 0, 0);*/
            }
        }
Exemple #4
0
        public Form1()
        {
            InitializeComponent();
            for (int i = 3; i < 255; i++)
            {
                this.cmbBoxIPID.Items.Add(string.Format("{0:X2}", i));
            }

            this.acnxConnection = new ActiveCNX();

            acnxConnection.onConnect    += new ActiveCNXConnectionEventHandler(acnxConnection_onConnect);
            acnxConnection.onDisconnect += new ActiveCNXConnectionEventHandler(acnxConnection_onDisconnect);
            acnxConnection.onError      += new ActiveCNXErrorEventHandler(acnxConnection_onError);
            acnxConnection.onDigital    += new ActiveCNXEventHandler(acnxConnection_onDigital);

            //I remembered that you can chain as many methods onto a delegate as you want, meaning we don't need a List of actions anymore.
            //Now instead of initializing several lists within the dictionary, we can just initialize it with a null delegate to start and
            //then add methods onto it as needed. Should be an easier syntax than dealing with the lists...
            Action del = null;

            audioSource.FeatureMode          = true;
            audioSource.AutomaticGainControl = false;
            audioSource.SystemMode           = SystemMode.OptibeamArrayOnly;

            RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers().Where(r => r.Id == RecognizerId).FirstOrDefault();

            if (ri == null)
            {
                MessageBox.Show("Could not find speech recognizer: {0}.", RecognizerId);
                return;
            }

            this.sre       = new SpeechRecognitionEngine(ri.Id);
            this.transport = new Choices(
                "play",
                "stop",
                "next channel",
                "previous channel",
                "cnn",
                "fox");

            var gb = new GrammarBuilder();

            gb.Culture = ri.Culture;
            gb.Append(transport);

            var g = new Grammar(gb);

            sre.LoadGrammar(g);

            this.actionMap = new Dictionary <string, Action>()
            {
                { "play", del },
                { "stop", del },
                { "pause", del },
            };

            actionMap["play"] += () =>
            {
                this.log.LogEvent("\nPlay command recognized");
                this.acnxConnection.SendDigital(0, 1, true);
                this.acnxConnection.SendDigital(0, 1, false);
            };

            actionMap["stop"] += () =>
            {
                this.log.LogEvent("\nStop command recognized");
                this.acnxConnection.SendDigital(0, 2, true);
                this.acnxConnection.SendDigital(0, 2, false);
            };

            actionMap["pause"] += () =>
            {
                this.log.LogEvent("\nPause command recognized");
                this.acnxConnection.SendDigital(0, 3, true);
                this.acnxConnection.SendDigital(0, 3, false);
            };

            //We could also do something like this, if we wanted a way to add actions at runtime; something like this
            //would let us add new actions to a given command while the form was running, which might be cool
            AddActionToMap("play", () => this.acnxConnection.SendDigital(1, 0, false));

            //To deal with the threading issue, I've moved the speech stuff into it's own class, which is how the ShapeGame
            //sample works. The Recognizer basically just takes an array of strings to set up a speech engine, and has it's
            //own SpeechRecognized event that we can hook onto - it basically just mirrors the standard SpeechRecognized event.
            //This means the Kinect stuff can have it's own little MTA threaded playground to fart around in, but the rest of
            //the code doesn't have to deal with any messy threading issues.
            recognizer = new Recognizer(this.actionMap.Keys.ToArray());
            this.recognizer.SaidSomething += sre_SpeechRecognized;
        }
Exemple #5
0
        public Form1()
        {
            InitializeComponent();
            for (int i = 3; i < 255; i++)
            {
                this.cmbBoxIPID.Items.Add(string.Format("{0:X2}", i));
            }

            this.acnxConnection = new ActiveCNX();

            acnxConnection.onConnect += new ActiveCNXConnectionEventHandler(acnxConnection_onConnect);
            acnxConnection.onDisconnect += new ActiveCNXConnectionEventHandler(acnxConnection_onDisconnect);
            acnxConnection.onError += new ActiveCNXErrorEventHandler(acnxConnection_onError);
            acnxConnection.onDigital += new ActiveCNXEventHandler(acnxConnection_onDigital);

            //I remembered that you can chain as many methods onto a delegate as you want, meaning we don't need a List of actions anymore.
            //Now instead of initializing several lists within the dictionary, we can just initialize it with a null delegate to start and
            //then add methods onto it as needed. Should be an easier syntax than dealing with the lists...
            Action del = null;

            audioSource.FeatureMode = true;
            audioSource.AutomaticGainControl = false;
            audioSource.SystemMode = SystemMode.OptibeamArrayOnly;

            RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers().Where(r => r.Id == RecognizerId).FirstOrDefault();
            if (ri == null)
            {
                MessageBox.Show("Could not find speech recognizer: {0}.", RecognizerId);
                return;
            }

            this.sre = new SpeechRecognitionEngine(ri.Id);
            this.transport = new Choices(
                "play",
                "stop",
                "next channel",
                "previous channel",
                "cnn",
                "fox");

            var gb = new GrammarBuilder();
            gb.Culture = ri.Culture;
            gb.Append(transport);

            var g = new Grammar(gb);

            sre.LoadGrammar(g);

            this.actionMap = new Dictionary<string, Action>()
            {
                {"play",del},
                {"stop",del},
                {"pause",del},
            };

            actionMap["play"] += () =>
                {
                    this.log.LogEvent("\nPlay command recognized");
                    this.acnxConnection.SendDigital(0, 1, true);
                    this.acnxConnection.SendDigital(0, 1, false);
                };

            actionMap["stop"] += () =>
                {
                    this.log.LogEvent("\nStop command recognized");
                    this.acnxConnection.SendDigital(0, 2, true);
                    this.acnxConnection.SendDigital(0, 2, false);
                };

            actionMap["pause"] += () =>
                {
                    this.log.LogEvent("\nPause command recognized");
                    this.acnxConnection.SendDigital(0, 3, true);
                    this.acnxConnection.SendDigital(0, 3, false);
                };

            //We could also do something like this, if we wanted a way to add actions at runtime; something like this
            //would let us add new actions to a given command while the form was running, which might be cool
            AddActionToMap("play", () => this.acnxConnection.SendDigital(1, 0, false));

            //To deal with the threading issue, I've moved the speech stuff into it's own class, which is how the ShapeGame
            //sample works. The Recognizer basically just takes an array of strings to set up a speech engine, and has it's
            //own SpeechRecognized event that we can hook onto - it basically just mirrors the standard SpeechRecognized event.
            //This means the Kinect stuff can have it's own little MTA threaded playground to fart around in, but the rest of
            //the code doesn't have to deal with any messy threading issues.
            recognizer = new Recognizer(this.actionMap.Keys.ToArray());
            this.recognizer.SaidSomething += sre_SpeechRecognized;
        }