示例#1
0
        public void HoldTimeDecrement()
        {
            if (registered)
            {
                double newHoldtime;

                if ((holdTime - 6553.5) >= 0)
                {
                    newHoldtime = QsysCoreManager.ScaleDown(holdTime - 6553.5);
                }
                else
                {
                    newHoldtime = QsysCoreManager.ScaleDown(0);
                }

                ComponentChange newChange = new ComponentChange()
                {
                    Params = new ComponentChangeParams()
                    {
                        Name = cName, Controls = new List <ComponentSetValue>()
                        {
                            new ComponentSetValue()
                            {
                                Name = "hold_time", Position = newHoldtime
                            }
                        }
                    }
                };

                QsysCoreManager.Cores[coreId].Enqueue(JsonConvert.SerializeObject(newChange, Formatting.None, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
        }
示例#2
0
        //add event handling
        private void Control_OnNewEvent(object o, QsysInternalEventsArgs e)
        {
            int intValue;

            if (!isInteger)
            {
                //QsysNamedControlEvent(this, new QsysEventsArgs(eQscEventIds.NamedControlChange, e.Name, Convert.ToBoolean(e.Value), Convert.ToUInt16(e.Value), e.SValue, null));

                if (newNamedControlChange != null)
                {
                    newNamedControlChange(Convert.ToUInt16(e.Value), e.SValue);
                }
            }
            else
            {
                intValue = (int)Math.Round(QsysCoreManager.ScaleUp(e.Position));

                //QsysNamedControlEvent(this, new QsysEventsArgs(eQscEventIds.NamedControlChange, e.Name, Convert.ToBoolean(intValue), intValue, Convert.ToString(e.Position), null));

                if (newNamedControlChange != null)
                {
                    newNamedControlChange(Convert.ToUInt16(intValue), intValue.ToString());
                }
            }
        }
示例#3
0
        public void ThresholdIncrement()
        {
            if (registered)
            {
                double newThreshold;

                if ((threshold + 6553.5) <= 65535)
                {
                    newThreshold = QsysCoreManager.ScaleDown(threshold + 6553.5);
                }
                else
                {
                    newThreshold = QsysCoreManager.ScaleDown(65535);
                }

                ComponentChange newChange = new ComponentChange()
                {
                    Params = new ComponentChangeParams()
                    {
                        Name = cName, Controls = new List <ComponentSetValue>()
                        {
                            new ComponentSetValue()
                            {
                                Name = "threshold", Position = newThreshold
                            }
                        }
                    }
                };

                QsysCoreManager.Cores[coreId].Enqueue(JsonConvert.SerializeObject(newChange, Formatting.None, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
        }
示例#4
0
        /// <summary>
        /// Initialzes all methods that are required to setup the class. Connection is established on port 1702.
        /// </summary>
        public void Initialize(string id, string host, ushort port, string username, string password, ushort useExternalConnection)
        {
            if (!isInitialized)
            {
                try
                {
                    coreId = id;

                    externalConnection = Convert.ToBoolean(useExternalConnection);

                    if (username.Length > 0)
                    {
                        this.username = username;
                    }
                    else
                    {
                        this.username = string.Empty;
                    }

                    if (password.Length > 0)
                    {
                        this.password = password;
                    }
                    else
                    {
                        this.password = string.Empty;
                    }

                    QsysCoreManager.AddCore(this);

                    if (debug == 1)
                    {
                        ErrorLog.Notice("QsysProcessor is initializing.");
                    }

                    commandQueue       = new CrestronQueue <string>();
                    responseQueue      = new CrestronQueue <string>();
                    commandQueueTimer  = new CTimer(CommandQueueDequeue, null, 0, 50);
                    responseQueueTimer = new CTimer(ResponseQueueDequeue, null, 0, 50);

                    client    = new TCPClientDevice();
                    client.ID = 1710;
                    client.ConnectionStatus += new StatusEventHandler(client_ConnectionStatus);
                    client.ResponseString   += new ResponseEventHandler(client_ResponseString);
                    client.Connect(host, port);
                }
                catch (Exception e)
                {
                    if (debug == 1 || debug == 2)
                    {
                        ErrorLog.Error("Error in QsysProcessor Iniitialize: {0}", e.Message);
                    }
                }
            }
        }
示例#5
0
        void QsysSignalPresence_OnNewEvent(object sender, QsysInternalEventsArgs e)
        {
            if (e.Name == "threshold")
            {
                threshold = (ushort)Math.Round(QsysCoreManager.ScaleUp(e.Position));

                if (newPeakThresholdChange != null)
                {
                    newPeakThresholdChange(e.SValue);
                }
            }
            else if (e.Name == "hold_time")
            {
                holdTime = (ushort)Math.Round(QsysCoreManager.ScaleUp(e.Position));

                if (newHoldTimeChange != null)
                {
                    newHoldTimeChange(e.SValue);
                }
            }
            else if (e.Name == "infinite_hold")
            {
                infiniteHold = Convert.ToBoolean(e.Value);

                if (newInfiniteHoldChange != null)
                {
                    newInfiniteHoldChange((ushort)e.Value);
                }
            }
            else if (e.Name.Contains("signal_presence"))
            {
                if (e.Name.Contains("signal_presence_"))
                {
                    var splitName = e.Name.Split('_');

                    if (newSignalPresenceChange != null)
                    {
                        newSignalPresenceChange(Convert.ToUInt16(splitName[2]), (ushort)e.Value);
                    }
                }
                else
                {
                    if (newSignalPresenceChange != null)
                    {
                        newSignalPresenceChange(1, (ushort)e.Value);
                    }
                }
            }
        }
示例#6
0
        void Component_OnNewEvent(object sender, QsysInternalEventsArgs e)
        {
            if (e.Name == "gain")
            {
                /*if (e.Value >= min && e.Value <= max)
                 * {
                 *  currentLvl = (int)Math.Round((65535 / (max - min)) * (e.Value + (min * (-1))));
                 *  QsysFaderEvent(this, new QsysEventsArgs(eQscEventIds.GainChange, cName, true, currentLvl, currentLvl.ToString()));
                 * }*/

                currentLvl = (int)Math.Round(QsysCoreManager.ScaleUp(e.Position));
                //QsysFaderEvent(this, new QsysEventsArgs(eQscEventIds.GainChange, cName, true, currentLvl, currentLvl.ToString(), null));

                if (newVolumeChange != null)
                {
                    newVolumeChange((ushort)currentLvl);
                }
            }
            else if (e.Name == "mute")
            {
                if (e.Value == 1)
                {
                    //QsysFaderEvent(this, new QsysEventsArgs(eQscEventIds.MuteChange, cName, true, 1, "true", null));
                    currentMute = true;
                }
                else if (e.Value == 0)
                {
                    //QsysFaderEvent(this, new QsysEventsArgs(eQscEventIds.MuteChange, cName, false, 0, "false", null));
                    currentMute = false;
                }

                if (newMuteChange != null)
                {
                    newMuteChange((ushort)e.Value);
                }
            }
            else if (e.Name == "max_gain")
            {
                max = e.Value;
            }
            else if (e.Name == "min_gain")
            {
                min = e.Value;
            }
        }
示例#7
0
        /// <summary>
        /// Sets the current volume.
        /// </summary>
        /// <param name="value">The volume level to set to.</param>
        public void Volume(int value)
        {
            if (registered)
            {
                ComponentChange newVolumeChange = new ComponentChange()
                {
                    Params = new ComponentChangeParams()
                    {
                        Name = cName, Controls = new List <ComponentSetValue>()
                        {
                            new ComponentSetValue()
                            {
                                Name = "gain", Position = QsysCoreManager.ScaleDown(value)
                            }
                        }
                    }
                };

                QsysCoreManager.Cores[coreId].Enqueue(JsonConvert.SerializeObject(newVolumeChange, Formatting.None, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
        }
示例#8
0
        public void SetInteger(int value, int scaled)
        {
            if (registered)
            {
                double newValue;
                ControlIntegerChange integer;

                if (scaled == 1)
                {
                    newValue = QsysCoreManager.ScaleDown(value);
                    integer  = new ControlIntegerChange()
                    {
                        Params = new ControlIntegerParams()
                        {
                            Name = cName, Position = newValue
                        }
                    };
                }
                else
                {
                    newValue = value;
                    integer  = new ControlIntegerChange()
                    {
                        Params = new ControlIntegerParams()
                        {
                            Name = cName, Value = newValue
                        }
                    };
                }



                QsysCoreManager.Cores[coreId].Enqueue(JsonConvert.SerializeObject(integer, Formatting.None, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
        }