Exemplo n.º 1
0
        object SendBufferProcess(object o)
        {
            while (!TxQueue.IsEmpty)
            {
                try
                {
                    Byte[] packet = TxQueue.Dequeue();
#if DEBUG
                    //CrestronConsole.Print("Samsung Tx: ");
                    //Tools.PrintBytes(packet, packet.Length);
#endif
                    if (programStopping)
                    {
                        TxQueue.Clear();
                        return(null);
                    }
                    else
                    {
                        this.ComPort.Send(packet, packet.Length);
                        CrestronEnvironment.AllowOtherAppsToRun();
                        Thread.Sleep(10);
                    }
                }
                catch (Exception e)
                {
                    if (e.Message != "ThreadAbortException")
                    {
                        ErrorLog.Exception(string.Format("{0} - Exception in tx buffer thread", GetType().Name), e);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        object ReceiveBufferProcess(object obj)
        {
            var bytes     = new Byte[1000];
            var byteIndex = 0;

            while (true)
            {
                try
                {
                    var b = _rxQueue.Dequeue();

                    if (_programStopping)
                    {
                        return(null);
                    }

                    if (b == 'x')
                    {
                        var copiedBytes = new byte[byteIndex];
                        Array.Copy(bytes, copiedBytes, byteIndex);
#if DEBUG
                        //CrestronConsole.Print("LG Rx: ");
                        //Tools.PrintBytes(copiedBytes, 0, copiedBytes.Length, true);
#endif
                        if (ReceivedData != null)
                        {
                            try
                            {
                                ReceivedData(copiedBytes);
                            }
                            catch (Exception e)
                            {
                                CloudLog.Exception(e);
                            }
                        }

                        byteIndex = 0;
                    }
                    else
                    {
                        bytes[byteIndex] = b;
                        byteIndex++;
                    }
                }
                catch (Exception e)
                {
                    if (e.Message != "ThreadAbortException")
                    {
#if DEBUG
                        //CrestronConsole.Print("Error in Lg Rx Handler: ");
                        //Tools.PrintBytes(bytes, 0, byteIndex);
#endif
                        CloudLog.Exception(string.Format("{0} - Exception in rx thread", GetType().Name), e);
                    }
                }

                CrestronEnvironment.AllowOtherAppsToRun();
                Thread.Sleep(0);
            }
        }
Exemplo n.º 3
0
        private ushort MakeRequest(Func <HttpsResult> action)
        {
            try
            {
                var response = action.Invoke();

                if (response == null)
                {
                    Debug.WriteError("HTTPS response object was null.");
                    return(0);
                }

                // Some HTTP(S) responses will not have a message body.
                if (response.Content == null)
                {
                    OnSimplHttpsClientResponse(response.Status, response.ResponseUrl, string.Empty, 0);
                }
                else
                {
                    foreach (var contentChunk in response.Content.SplitIntoChunks(255))
                    {
                        OnSimplHttpsClientResponse(response.Status, response.ResponseUrl, contentChunk, response.Content.Length);
                        CrestronEnvironment.Sleep(10); // allow a little bit for things to process
                    }
                }

                return((ushort)response.Status);
            }
            catch (Exception ex)
            {
                Debug.WriteException(ex);
                return(0);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Acquires the lock in shared mode, busy waiting
        ///     if necessary.
        /// </summary>
        /// <remarks>
        ///     Exclusive acquires are *not* given precedence over shared
        ///     acquires for busy wait methods.
        /// </remarks>
        public IDisposable SpinAcquireShared()
        {
            int ncount = 0;

            while (true)
            {
                int value = _value;

                if ((value & ExclusiveMask) == 0)
                {
                    if ((value & LockOwned) == 0)
                    {
                        if (Interlocked.CompareExchange(ref _value, value + LockOwned + LockSharedOwnersIncrement, value) == value)
                        {
                            break;
                        }
                    }
                    else if (((value >> LockSharedOwnersShift) & LockSharedOwnersMask) != 0)
                    {
                        if (Interlocked.CompareExchange(ref _value, value + LockSharedOwnersIncrement, value) == value)
                        {
                            break;
                        }
                    }
                }

                CrestronEnvironment.Sleep(++ncount % 10 == 0 ? 1 : 0);
            }

            return(_fastResourceLockContext);
        }
Exemplo n.º 5
0
        public void Dial(string chanNum)
        {
            if (DialIsRunning || !InitSuccess)
            {
                return;
            }
            if (DialFunctions == null)
            {
                Debug.Console(1, "DevicePresets '{0}', not attached to keypad device. Ignoring channel", Key);
                return;
            }

            DialIsRunning = true;
            CrestronInvoke.BeginInvoke(o =>
            {
                foreach (var c in chanNum.ToCharArray())
                {
                    if (DialFunctions.ContainsKey(c))
                    {
                        Pulse(DialFunctions[c]);
                    }
                    CrestronEnvironment.Sleep(DigitSpacingMS);
                }

                if (EnterFunction != null)
                {
                    Pulse(EnterFunction);
                }
                DialIsRunning = false;
            });
        }
Exemplo n.º 6
0
        private void CreatePortMapAsync(object obj)
        {
            CreatePortMapAsyncState state = obj as CreatePortMapAsyncState;

            UdpClient udpClient = new UdpClient();
            CreatePortMapListenState listenState = new CreatePortMapListenState(state, udpClient);

            int attempt = 0;
            int delay   = PmpConstants.RetryDelay;

            ThreadPool.QueueUserWorkItem(new WaitCallback(CreatePortMapListen), listenState);

            while (attempt < PmpConstants.RetryAttempts && !listenState.Success)
            {
                udpClient.Send(state.Buffer, state.Buffer.Length, new IPEndPoint(localAddress, PmpConstants.ServerPort));
                listenState.UdpClientReady.Set();

                attempt++;
                delay *= 2;
#if SSHARP
                CrestronEnvironment.Sleep(delay);
#else
                Thread.Sleep(delay);
#endif
            }

            state.Success = listenState.Success;

            udpClient.Close();
            state.ResetEvent.Set();
        }
Exemplo n.º 7
0
        private object SendBufferProcess(object o)
        {
            while (true)
            {
                try
                {
                    var bytes = _txQueue.Dequeue();
                    if (bytes == null)
                    {
                        CloudLog.Notice("Exiting {0}", Thread.CurrentThread.Name);
                        return(null);
                    }
#if DEBUG
                    Debug.WriteInfo("Samsung Tx",
                                    Debug.AnsiPurple + Tools.GetBytesAsReadableString(bytes, 0, bytes.Length, false) +
                                    Debug.AnsiReset);
#endif
                    _comPort.Send(bytes, bytes.Length);
                    CrestronEnvironment.AllowOtherAppsToRun();
                    Thread.Sleep(10);
                }
                catch (Exception e)
                {
                    if (e.Message != "ThreadAbortException")
                    {
                        CloudLog.Exception(string.Format("{0} - Exception in tx buffer thread", GetType().Name), e);
                    }
                }
            }
        }
Exemplo n.º 8
0
 private void client_ConnectionStatus(int _status, int _id)
 {
     try
     {
         if (_status == 2 && !isConnected)
         {
             this.isConnected = true;
             foreach (var item in this.SimplClients)
             {
                 item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsConnected, (SimplSharpString)"true", 1));
             }
             CrestronEnvironment.Sleep(1500);
         }
         else if (this.isConnected && _status != 2)
         {
             ErrorLog.Error("Qsys Core {0} disconnected!", this.coreID);
             this.isConnected   = false;
             this.isInitialized = false;
             this.heartbeatTimer.Dispose();
             foreach (var item in this.SimplClients)
             {
                 item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsRegistered, (SimplSharpString)"false", 0));
                 item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsConnected, (SimplSharpString)"false", 0));
             }
         }
     }
     catch (Exception e)
     {
         ErrorLog.Error("Qsys Core {0} connection failure {1} - {2}", this.coreID, e.Message, e.StackTrace);
     }
 }
Exemplo n.º 9
0
        object SendThreadProcess(object o)
        {
#if DEBUG
            CrestronConsole.PrintLine("{0}.SendThreadProcess() Start", this.GetType().Name);
#endif
            while (!_sendQueue.IsEmpty)
            {
                byte[]           data = _sendQueue.Dequeue();
                SocketErrorCodes err  = SendPacket(_client, data);

#if DEBUG
                CrestronConsole.PrintLine("{0} Send process result - {1}", this.GetType().Name, err);
#endif

                if (err != SocketErrorCodes.SOCKET_OK)
                {
                    ErrorLog.Error("{0}.Send process - Error sending data to socket, {1}", this.GetType().Name, err);
                }

                CrestronEnvironment.AllowOtherAppsToRun();
                Thread.Sleep(0);
            }

#if DEBUG
            CrestronConsole.PrintLine("{0}.SendThreadProcess() End", this.GetType().Name);
#endif

            return(null);
        }
Exemplo n.º 10
0
        void client_ConnectionStatus(int status, int id)
        {
            if (status == 2 && !isConnected)
            {
                this.isConnected = true;
                foreach (var item in SimplClients)
                {
                    item.Value.Fire(new SimplEventArgs(eElkSimplEventIds.IsConnected, "true", 1));
                }
                CrestronEnvironment.Sleep(1500);

                foreach (var item in SimplClients)
                {
                    item.Value.Fire(new SimplEventArgs(eElkSimplEventIds.IsRegistered, "true", 1));
                }
                this.InitializePanelParameters();
            }
            else if (isConnected && status != 2)
            {
                this.SendDebug("Elk Disconnected");
                this.isConnected = false;
                //foreach (var item in SimplClients)
                //{
                //    //item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsRegistered, "false", 0));
                //    //item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsConnected, "false", 0));
                //}
            }
        }
Exemplo n.º 11
0
        private static void SearchAndListen()
#endif
        {
            while (true)
            {
                searching.WaitOne();

                try
                {
                    Receive(UpnpSearcher.Instance, UpnpSearcher.sockets);
                    Receive(PmpSearcher.Instance, PmpSearcher.sockets);

                    foreach (ISearcher s in controllers)
                    {
                        if (s.NextSearch < DateTime.Now)
                        {
                            Log("Searching for: {0}", s.GetType().Name);
                            s.Search();
                        }
                    }
                }
                catch (Exception e)
                {
                    if (UnhandledException != null)
                    {
                        UnhandledException(typeof(NatUtility), new UnhandledExceptionEventArgs(e, false));
                    }
                }
#if SSHARP
                CrestronEnvironment.Sleep(10);
#else
                System.Threading.Thread.Sleep(10);
#endif
            }
        }
Exemplo n.º 12
0
        void HandleQueue(object o)
        {
            while (true)
            {
                try
                {
                    var data = _queue.Dequeue();
                    if (data == null)
                    {
                        return;
                    }

                    if (Debug)
                    {
                        CrestronConsole.PrintLine("Sennheiser - {0} - Sending data: {1}", _client.AddressToAcceptConnectionFrom, data);
                    }

                    if (_connected)
                    {
                        var bytes = _encoding.GetBytes(data);
                        _client.SendData(bytes, bytes.Length);
                        CrestronEnvironment.Sleep(25);
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog.Error("Sennheiser - Exception in UdpTransport.HandleQueue: " + ex.Message);
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Attempts to acquire the mutex and returns after a
        /// timeout period if the mutex could not be acquired.
        /// </summary>
        /// <param name="millisecondsTimeout">The timeout, in milliseconds.</param>
        /// <returns>Whether or not the mutex was acquired.</returns>
        public bool TryAcquire(int millisecondsTimeout)
        {
            if (Monitor.TryEnter(_lock))
            {
                return(true);
            }

            if (millisecondsTimeout == 0)
            {
                return(false);
            }

            DateTime endtime = DateTime.Now.AddMilliseconds(millisecondsTimeout);

            while (DateTime.Now < endtime)
            {
                if (Monitor.TryEnter(_lock))
                {
                    return(true);
                }
                CrestronEnvironment.Sleep(1);
            }

            return(Monitor.TryEnter(_lock));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Sets the temperature for the passenger's climate control
        /// </summary>
        /// <param name="desiredTemperature">The value to which the climate control should be set</param>
        public void HvacSetPassengerLevel(int desiredTemperature)
        {
            decimal            convertedLevel;
            HvacSetLevelResult result;
            string             rounded;

            try
            {
                HvacSetTempUnits();

                if (Settings.TemperatureUnits == "F")
                {
                    rounded = Calculators.GetTempCelsiusFromFarenheit(Convert.ToDecimal(desiredTemperature)).ToString("0.##");
                }
                else
                {
                    rounded = desiredTemperature.ToString();
                }

                convertedLevel = Convert.ToDecimal(rounded);
                result         = new HvacSetLevelResult(convertedLevel, HvacSetLevelResult.TempLocations.Passenger);
                result.GetResult();
                CrestronEnvironment.Sleep(2000);
                result.GetResult();
            }
            catch (Exception ex)
            {
                CrestronConsole.PrintLine("SimplTeslaCar.Main.HvacSetPassengerLevel()::Error Setting Passenger HVAC: " + ex.ToString());
            }
        }
Exemplo n.º 15
0
        private static object FileWriteProcess(object userSpecific)
        {
            Notice("CloudLog FileWriteProcess Started");

            while (true)
            {
                CrestronEnvironment.AllowOtherAppsToRun();

                var log = FileWriteQueue.Dequeue();

                using (var writer = CurrentLogFile.AppendText())
                {
                    writer.WriteLine(log);
                    while (!FileWriteQueue.IsEmpty)
                    {
                        writer.WriteLine(FileWriteQueue.Dequeue());
                    }
                }

                if (_programEnding && FileWriteQueue.IsEmpty)
                {
                    return(null);
                }
            }
        }
Exemplo n.º 16
0
        object ReceiveBufferProcess(object obj)
        {
            Byte[] bytes     = new Byte[1000];
            int    byteIndex = 0;

            while (true)
            {
                try
                {
                    byte b = RxQueue.Dequeue();

                    if (programStopping)
                    {
                        return(null);
                    }

                    if (b == 10)
                    {
                        // skip line feed
                    }

                    // If find byte = CR
                    else if (b == 13)
                    {
                        // Copy bytes to new array with length of packet and ignoring the CR.
                        Byte[] copiedBytes = new Byte[byteIndex];
                        Array.Copy(bytes, copiedBytes, byteIndex);

                        byteIndex = 0;
#if DEBUG
                        CrestronConsole.Print("Revolabs Rx: ");
                        Tools.PrintBytes(copiedBytes, copiedBytes.Length, true);
#endif
                        if (ReceivedData != null)
                        {
                            ReceivedData(this, Encoding.ASCII.GetString(copiedBytes, 0, copiedBytes.Length));
                        }
                        CrestronEnvironment.AllowOtherAppsToRun();
                    }
                    else
                    {
                        bytes[byteIndex] = b;
                        byteIndex++;
                    }
                }
                catch (Exception e)
                {
                    if (e.Message != "ThreadAbortException")
                    {
#if DEBUG
                        CrestronConsole.Print("Error in Revolabs Rx: ");
                        Tools.PrintBytes(bytes, byteIndex);
#endif
                        ErrorLog.Exception(string.Format("{0} - Exception in rx thread", GetType().Name), e);
                    }
                }
            }
        }
Exemplo n.º 17
0
        internal void QueueRequest(ServerRequest request)
        {
            RequestQueue.Enqueue(request);

            if (_dispatchThread != null && _dispatchThread.ThreadState == Thread.eThreadStates.ThreadRunning)
            {
                return;
            }

            _dispatchThread = new Thread(specific =>
            {
#if true
                Debug.WriteSuccess("AvediaServer", "Launching {0}.DispacthThread, Request Count = {1}", GetType().Name,
                                   RequestQueue.Count);
                Debug.WriteInfo("AvediaServer", "HttpClient Timeout = {0}, TimeoutEnabled = {1}", HttpClient.Timeout,
                                HttpClient.TimeoutEnabled);
#endif

                while (true)
                {
                    var r = RequestQueue.Dequeue();
                    if (request == null)
                    {
                        CloudLog.Info("Exiting {0}", Thread.CurrentThread.Name);
                        return(null);
                    }
#if true
                    CrestronConsole.PrintLine("{0} {1}", r.RequestType.ToString(), r.Url);
                    if (r.RequestType == RequestType.Post)
                    {
                        CrestronConsole.PrintLine(r.ContentString);
                    }
#endif
                    try
                    {
                        var response = HttpClient.Dispatch(r);

                        try
                        {
                            r.Callback(response, HTTP_CALLBACK_ERROR.COMPLETED);
                        }
                        catch (Exception e)
                        {
                            CloudLog.Exception(e);
                        }
                    }
                    catch
                    {
                        r.Callback(null, HTTP_CALLBACK_ERROR.UNKNOWN_ERROR);
                    }

                    CrestronEnvironment.AllowOtherAppsToRun();
                }
            }, null)
            {
                Name = "Avedia HTTP dispatch process"
            };
        }
Exemplo n.º 18
0
        /// <summary>
        /// Gets a correctly formatted timestamp.
        /// </summary>
        /// <returns>A <see langword="string"/> with a properly formatted timestamp.</returns>
        private static string GetTimestamp()
        {
            if (Options.Instance.Use24HourTime)
            {
                return(CrestronEnvironment.GetLocalTime().ToString("HH:mm:ss"));
            }

            return(CrestronEnvironment.GetLocalTime().ToLongTimeString());
        }
Exemplo n.º 19
0
        //public void OSD_EnterSetup() { SystemMonitor.OSDInformation.InSetupMode = true; }
        //public void OSD_ExitSetup() { SystemMonitor.OSDInformation.InSetupMode = false; }


        public bool TimeZone(int Zone)
        {
            var result = CrestronEnvironment.SetTimeZone(Zone);

            if (!result)
            {
                ErrorLog.Notice("An attemt to set an undetermined Time Zone was made");
            }
            return(result);
        }
Exemplo n.º 20
0
 // client connect callback method
 void PJLinkConnectCallBack(TCPClient Client)
 {
     if (Client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED)
     {
         Client.ReceiveDataAsync(PJLinkReceiveDataCallback); // set up callback when data received
     }
     else
     {
         CrestronEnvironment.Sleep(2000);
         Client.ConnectToServerAsync(PJLinkConnectCallBack);  // connection failed, try again
     }
 }
        /// <summary>
        ///
        /// </summary>
        protected override void EndShutdown()
        {
            VideoCodec.EndAllCalls();

            SetDefaultLevels();

            RunDefaultPresentRoute();

            CrestronEnvironment.Sleep(1000);

            RunRouteAction("roomOff");
        }
Exemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        public void StatusGet()
        {
            PowerGet();

            CrestronEnvironment.Sleep(100);

            InputGet();

            CrestronEnvironment.Sleep(100);

            VolumeGet();
        }
Exemplo n.º 23
0
        /// <summary>
        ///
        /// </summary>
        protected override void EndShutdown()
        {
            SetDefaultLevels();

            RunDefaultPresentRoute();

            CrestronEnvironment.Sleep(1000);

            Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room");

            RunRouteAction("roomOff");
        }
Exemplo n.º 24
0
 private INTEGER MakeRequest(Func <HttpsResult> action)
 {
     using (_httpsOperationLock.AquireLock())
     {
         var response = action.Invoke();
         foreach (var contentChunk in response.Content.SplitIntoChunks(250))
         {
             OnSimplHttpsClientResponse(response.Status, response.ResponseUrl, contentChunk);
             CrestronEnvironment.Sleep(10); // allow for things to process
         }
         return((INTEGER)response.Status);
     }
 }
 /// <summary>
 /// On monitor connect, restart the operation
 /// </summary>
 void MonitorClient_IsReadyForComm(object sender, GenericTcpServerClientReadyForcommunicationsEventArgs args)
 {
     if (args.IsReady)
     {
         Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Monitor client connection success. Disconnecting in 2s");
         MonitorClientTimer.Stop();
         MonitorClientTimer        = null;
         MonitorClientFailureCount = 0;
         CrestronEnvironment.Sleep(2000);
         StopMonitorClient();
         StartMonitorClient();
     }
 }
Exemplo n.º 26
0
 public void VolumeDown(bool pressRelease)
 {
     //while (pressRelease)
     //{
     Debug.Console(2, this, "Volume Up {0}", pressRelease);
     if (pressRelease)
     {
         var newLevel = _FakeVolumeLevel - VolumeInterval;
         SetVolume((ushort)newLevel);
         CrestronEnvironment.Sleep(VolumeHeldRepeatInterval);
     }
     //}
 }
Exemplo n.º 27
0
 // client connect callback method
 void ConnectCallBack(TCPClient Client)
 {
     if (Client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED)
     {
         Client.ReceiveDataAsync(ReceiveDataCallback); // set up callback when data received
     }
     else
     {
         CrestronEnvironment.Sleep(2000);
         Client.ConnectToServerAsync(ConnectCallBack);  // connection failed, try again
         CrestronConsole.PrintLine("Attempting to reconnect PJLink Projector");
     }
 }
Exemplo n.º 28
0
        /// <summary>
        /// Gets the current processor info
        /// </summary>
        public void GetProcessorInfo()
        {
            OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);

            try
            {
                var processor = new ProcessorInfo();
                processor.Model              = InitialParametersClass.ControllerPromptName;
                processor.SerialNumber       = CrestronEnvironment.SystemInfo.SerialNumber;
                processor.ModuleDirectory    = InitialParametersClass.ProgramDirectory.ToString();
                processor.ProgramIdTag       = InitialParametersClass.ProgramIDTag;
                processor.DevicePlatform     = CrestronEnvironment.DevicePlatform.ToString();
                processor.OsVersion          = CrestronEnvironment.OSVersion.Version.ToString();
                processor.RuntimeEnvironment = CrestronEnvironment.RuntimeEnvironment.ToString();
                processor.LocalTimeZone      = CrestronEnvironment.GetTimeZone().Offset;

                // Does not return firmware version matching a "ver" command
                // returns the "ver -v" 'CAB' version
                // example return ver -v:
                //		RMC3 Cntrl Eng [v1.503.3568.25373 (Oct 09 2018), #4001E302] @E-00107f4420f0
                //		Build: 14:05:46  Oct 09 2018 (3568.25373)
                //		Cab: 1.503.0070
                //		Applications:  1.0.6855.21351
                //		Updater: 1.4.24
                //		Bootloader: 1.22.00
                //		RMC3-SetupProgram: 1.003.0011
                //		IOPVersion: FPGA [v09] slot:7
                //		PUF: Unknown
                //Firmware = CrestronEnvironment.OSVersion.Firmware;
                //Firmware = InitialParametersClass.FirmwareVersion;

                // Use below logic to get actual firmware ver, not the 'CAB' returned by the above
                // matches console return of a "ver" and on SystemInfo page
                // example return ver:
                //		RMC3 Cntrl Eng [v1.503.3568.25373 (Oct 09 2018), #4001E302] @E-00107f4420f0
                var response = "";
                CrestronConsole.SendControlSystemCommand("ver", ref response);
                processor.Firmware     = ParseConsoleResponse(response, "Cntrl Eng", "[", "(");
                processor.FirmwareDate = ParseConsoleResponse(response, "Cntrl Eng", "(", ")");

                OnProcessorChange(processor, 0, SystemInfoConstants.ProcessorConfigChange);
            }
            catch (Exception e)
            {
                var msg = string.Format("GetProcessorInfo failed: {0}", e.Message);
                CrestronConsole.PrintLine(msg);
                //ErrorLog.Error(msg);
            }

            OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
        }
Exemplo n.º 29
0
        /// <summary>
        ///     Waits for the event to be set by busy waiting.
        /// </summary>
        public void SpinWait()
        {
            if ((_value & EventSet) != 0)
            {
                return;
            }

            int ncount = 0;

            while ((_value & EventSet) == 0)
            {
                CrestronEnvironment.Sleep(++ncount % 10 == 0 ? 1 : 0);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Gets a correctly formatted timestamp.
        /// </summary>
        /// <returns>A <see langword="string"/> with a properly formatted timestamp.</returns>
        private static string GetTimestamp()
        {
            if (!Options.Instance.UseTimestamps)
            {
                return(string.Empty);
            }

            if (Options.Instance.Use24HourTime)
            {
                return(string.Format("[{0}]", CrestronEnvironment.GetLocalTime().ToString("HH:mm:ss")));
            }

            return(string.Format("[{0}]", CrestronEnvironment.GetLocalTime().ToLongTimeString()));
        }