Ejemplo n.º 1
0
        public SimplSharpString analogToEis5(int analogIn)
        {
            float            myFloatVariable  = (float)analogIn / 100;
            SimplSharpString strFormattedDate = myFloatVariable.ToString("n2");

            return(strFormattedDate);
        }
Ejemplo n.º 2
0
        public void Initialize(ushort _coreID, SimplSharpString _namedControl, ushort _controlType)
        {
            eControlType t = (eControlType)Enum.Parse(typeof(eControlType), Convert.ToString(_controlType), true);

            this.nc = new QsysNamedControl((int)_coreID, _namedControl.ToString(), t);
            this.nc.QsysNamedControlEvent += new EventHandler <QsysEventsArgs>(namedControl_QsysNamedControlEvent);
        }
Ejemplo n.º 3
0
        public void Initialize(SimplSharpString setToken)
        {
            apiToken = setToken.ToString();
            debug("PBServer.Initialize");

            checkPushes();
            openWebsocket();
        }
Ejemplo n.º 4
0
        void ServerHttpRequestHandler(object sender, OnHttpRequestArgs e)
        {
            Trace("ServerHttpRequestHandler() received request. Path: " + e.Request.Path);
            SimplSharpString answer = RequestCallbackNotify(e.Request.Path);

            CrestronConsole.PrintLine("ANSWER: " + answer.ToString());
            e.Response.ContentString = answer.ToString();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// send data to server
        /// </summary>
        /// <param name="tx">data</param>
        public void DataTransmit(SimplSharpString tx)
        {
            var err = new SocketErrorCodes();

            byte[] bytes = Encoding.UTF8.GetBytes(tx.ToString());
            err = _tcpClient.SendData(bytes, bytes.Length);
            Debug("Data transmitted: " + tx.ToString(), ErrorLevel.None, err.ToString());
        }
Ejemplo n.º 6
0
 public void broadcast(SimplSharpString data)
 {
     foreach (uint clientIdex in this.clients)
     {
         byte[] db = this.trans(System.Text.Encoding.BigEndianUnicode.GetBytes(data.ToString()));
         this.server.SendData(clientIdex, db, db.Length);
     }
 }
Ejemplo n.º 7
0
 private void sendTrace(SimplSharpString msg)
 {
     if (this.SendTrace == null)
     {
         return;
     }
     this.SendTrace(msg);
 }
Ejemplo n.º 8
0
        public void SendData(SimplSharpString dataToSend)
        {
            byte[]           pBufferToSend = System.Text.Encoding.ASCII.GetBytes(dataToSend.ToString());
            SocketErrorCodes returnCode    = tcpClient.SendData(pBufferToSend, pBufferToSend.Length);

            if (debug > 0)
            {
                CrestronConsole.PrintLine("\n TCPClientClass SendData returnCode: " + returnCode.ToString());
            }
        }
Ejemplo n.º 9
0
 public void OnDataReceiveEventCallback(TCPClient myTCPClient, int numberOfBytesReceived)
 {
     if (numberOfBytesReceived > 0)
     {
         SimplSharpString data = new SimplSharpString();
         data = System.Text.Encoding.Default.GetString(tcpClient.IncomingDataBuffer, 0, numberOfBytesReceived);
         OnDataReceiveEvent(data);
     }
     tcpClient.ReceiveDataAsync(OnDataReceiveEventCallback);
 }
        public void ONTRACE(SimplSharpString STRACE)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 61;
                /* Trace( "{0}", STRACE  .ToString() ) */;
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 11
0
 public void Send(SimplSharpString data)
 {
     if (client != null)
     {
         Pacer.EnqueueTX(data);
     }
     else
     {
         Logger.Log("Error: Send() to a Null client!");
     }
 }
        public void CALLBACKEVENTHANDLER(SimplSharpString KEY, ushort VALUE)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 144;
                OUT.Value = (ushort)(VALUE);
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"></param>
        /// <param name="delim"></param>
        /// <returns>string</returns>
        public void SplitString(string str, string delim)
        {
            var strings = str.Split(delim.ToCharArray());

            SimplSharpString[] splitStrs = new SimplSharpString[strings.Length];
            for (int i = 0; i < strings.Length; i++)
            {
                splitStrs[i] = (SimplSharpString)strings[i];
                CallbackEvent(splitStrs[i], (ushort)i);
            }
        }
        public void FROMSSHARP(SimplSharpString _TITLE)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 15;
                TITLE.UpdateValue("S+ Callback. Movie title: " + _TITLE.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 15
0
        public void UPDATETWOBYTEEIS5DECIMALVALUETEXTCALLBACK(SimplSharpString VALUE)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 144;
                EIS5DECIMALVALUETEXT.UpdateValue(VALUE.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 16
0
        public void RECEIVEERROR(SimplSharpString SERROR)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 36;
                STATUS.UpdateValue(SERROR.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 17
0
        public void NEWSTRINGCHANGE(ushort X, SimplSharpString VALUE)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 34;
                STRINGVALUE.UpdateValue(VALUE.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
        public void NEWINTEGERCHANGE(ushort VALUE, SimplSharpString X)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 34;
                INTEGERVALUE.Value         = (ushort)(VALUE);
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 19
0
        public void NEWCURRENTCALLSTATUSCHANGE(SimplSharpString STATUS)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 151;
                CALLSTATUS.UpdateValue(STATUS.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 20
0
        public void NEWRECENTCALLLISTEVENT(SimplSharpString XSIG)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 165;
                RECENTCALLXSIG.UpdateValue(XSIG.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 21
0
        public void NEWCURRENTLYCALLINGEVENT(SimplSharpString NEWCURRENTLYCALLING)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 146;
                CURRENTLYCALLING.UpdateValue(NEWCURRENTLYCALLING.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 22
0
        public void RECEIVEGROUP(ushort NID, SimplSharpString SNAME)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 46;
                GROUPNAME [NID].UpdateValue(SNAME.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
        public void CALLBACKEVENTHANDLER(SimplSharpString KEY, SimplSharpString VALUE)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 142;
                OUT.UpdateValue(VALUE.ToString());
            }
            finally { ObjectFinallyHandler(); }
        }
        public void CALLBACKPULSEEVENTHANDLER(SimplSharpString KEY)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 149;
                Functions.Pulse(20, OUT);
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 25
0
 public static void SubmoduleRx(SimplSharpString key, SimplSharpString value)
 {
     try
     {
         changeEventArgs.key         = key;
         changeEventArgs.stringValue = value;
         onSubmoduleEvent(null, changeEventArgs);
     }
     catch (Exception e)
     {
         ErrorLog.Error("StaticClassTemplate SubmoduleRx Exception: " + e.Message);
     }
 }
Ejemplo n.º 26
0
        /// <summary>
        /// create buffer for incoming data and pass to S+
        /// </summary>
        /// <param name="client">tcp client</param>
        /// <param name="bytes">buffer size</param>
        private void OnDataReceiveEventCallback(TCPClient client, int bytes)
        {
            byte[] rxBuffer;
            var    rxToSplus = new SimplSharpString();

            if (bytes > 0)
            {
                rxBuffer  = _tcpClient.IncomingDataBuffer;
                rxToSplus = Encoding.Default.GetString(rxBuffer, 0, bytes);
                ReceiveData(rxToSplus);
            }
            _tcpClient.ReceiveDataAsync(OnDataReceiveEventCallback);
        }
Ejemplo n.º 27
0
        //-------------------------------------//
        //    Function | AddMailRecipient
        // Description | ...
        //-------------------------------------//

        public static void AddMailRecipient(SimplSharpString addr)
        {
            if (mailRecipients == null)
            {
                mailRecipients = new List <string> ();
            }

            if (addr.ToString().Contains("@") && !mailRecipients.Contains(addr.ToString()))
            {
                mailRecipients.Add(addr.ToString());
                CrestronConsole.PrintLine("Added new email recipient: {0}", addr.ToString());
            }
        }
Ejemplo n.º 28
0
        public void EnqueueTX(SimplSharpString data)
        {
            string sdata = data.ToString();

            bMutex.WaitForMutex();

            foreach (string s in data.ToString().Split(';'))
            {
                if (!string.IsNullOrEmpty(s))
                {
                    SendQueue.Enqueue(s);
                }
            }
            bMutex.ReleaseMutex();
        }
Ejemplo n.º 29
0
 public void Initialize(ushort _coreID, SimplSharpString _host, ushort _port, SimplSharpString _user, SimplSharpString _pass)
 {
     this.core = QsysMain.AddOrGetCoreObject(_coreID);
     if (core.Initialize((int)_coreID, _host.ToString(), _port, _user.ToString(), _pass.ToString()))
     {
         core.setDebug(debug);
         core.RegisterSimplClient(Convert.ToString(_coreID));
         core.SimplClients[Convert.ToString(_coreID)].OnNewEvent += new EventHandler <SimplEventArgs>(QsysProcessor_SimplEvent);
         this.isRegistered = true;
     }
     else
     {
         //TODO: Remove all changegroups and re-add all, re-sync
     }
 }
Ejemplo n.º 30
0
        public void NEWCORESTATUS(SimplSharpString DNAME, ushort REDUNDANT, ushort EMULATOR)
        {
            try
            {
                SplusExecutionContext __context__ = SplusSimplSharpDelegateThreadStartCode();

                __context__.SourceCodeLine = 46;
                DESIGNNAME.UpdateValue(DNAME.ToString());
                __context__.SourceCodeLine = 47;
                ISREDUNDANT.Value          = (ushort)(REDUNDANT);
                __context__.SourceCodeLine = 48;
                ISEMULATOR.Value           = (ushort)(EMULATOR);
            }
            finally { ObjectFinallyHandler(); }
        }
Ejemplo n.º 31
0
 public void Connect(SimplSharpString Address, int Port)
 {
     try
     {
         if (socket != null) Disconnect();
         uniqueToken = (uint)System.DateTime.Now.TimeOfDay.Milliseconds;
         socket = new UDPServer(Address.ToString(), Port, MAX_PACKET_SIZE);
         if (socket.EnableUDPServer() != SocketErrorCodes.SOCKET_OK)
         {
             ErrorLog.Error("Socket enable error Kodi SIMPL#: {0}", socket.EnableUDPServer());
         }
     }
     catch (Exception e)
     {
         ErrorLog.Exception("Exception Kodi SIMPL#: {0}", e);
     }
 }
Ejemplo n.º 32
0
        /************************************************************************/
        /* SendAction - Payload format                                          */
        /* %c - action type                                                     */
        /* %s - action message                                                  */
        /************************************************************************/
        public void SendAction(SimplSharpString MessageString)
        {
            string Message = MessageString.ToString();

            byte[] payload = new byte[Message.Length + 2];

            int offset = 0;

            payload[offset++] = (byte)0x01;

            for (int i = 0; i < Message.Length; i++)
                payload[offset++] = (byte)Message[i];
            payload[offset++] = (byte)'\0';

            Send(PacketType.PT_ACTION, payload);
        }
Ejemplo n.º 33
0
        public void Initialize(SimplSharpString setToken)
        {
            apiToken = setToken.ToString();
            debug("PBServer.Initialize");

            checkPushes();
            openWebsocket();
        }