Пример #1
2
        /// <summary>
        /// Constructor of the Control System Class. Make sure the constructor always exists.
        /// If it doesn't exit, the code will not run on your 3-Series processor.
        /// </summary>
        public ControlSystem()
            : base()
        {
            // subscribe to control system events
            CrestronEnvironment.SystemEventHandler += new SystemEventHandler(CrestronEnvironment_SystemEventHandler);
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
            CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);

            // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should
            // define the max number of threads which we will use in the system.
            // the right number depends on your project; do not make this number unnecessarily large
            Thread.MaxNumberOfUserThreads = 20;

            // ensure this processor has ethernet
            if (this.SupportsEthernet)
            {
                // create new dmtx401c object and subscribe to its events
                dmTx = new DmTx401C(0x03, this);	// IPID for the dmtx is 3
                dmTx.BaseEvent += dmTx_BaseEvent;
                dmTx.HdmiInput.InputStreamChange += HdmiInput_InputStreamChange;
                dmTx.HdmiInput.VideoAttributes.AttributeChange += Hdmi_AttributeChange;
                dmTx.VgaInput.InputStreamChange += VgaInput_InputStreamChange;
                dmTx.VgaInput.VideoAttributes.AttributeChange += Vga_AttributeChange;
                dmTx.DisplayPortInput.InputStreamChange += DisplayPortInput_InputStreamChange;
                dmTx.DisplayPortInput.VideoAttributes.AttributeChange += DisplayPort_AttributeChange;
                dmTx.OnlineStatusChange += Device_OnlineStatusChange;

                // create new tt100 object using the dmtx401 constructor, and subscribe to its events
                connectIt = new Tt1xx(dmTx);
                connectIt.ButtonStateChange += connectIt_ButtonStateChange;
                connectIt.OnlineStatusChange += Device_OnlineStatusChange;

                // register the dmtx to this program, the tt100 will be registered as part of the dmtx
                if (dmTx.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> The DM-TX-401-c has been registered successfully");
                else
                    ErrorLog.Error(">>> The DM-TX-401-C was not registered: {0}", dmTx.RegistrationFailureReason);

                // create new dmrmc100c object and subscribe to its events
                dmRmc = new DmRmcScalerC(0x04, this);	// IPID for the dmtx is 4
                dmRmc.DmInput.InputStreamChange += DmRmc_InputStreamChange;
                dmRmc.ComPorts[1].SerialDataReceived += DmRmc_SerialDataReceived;
                dmRmc.OnlineStatusChange += Device_OnlineStatusChange;
                dmRmc.Scaler.OutputChange += Scaler_OutputChange;

                // register device with the control system
                if (dmRmc.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> The DM-RMC-Scaler-C has been registered successfully");
                else
                    ErrorLog.Error(">>> The DM-RMC-Scaler-C was not registered: {0}", dmRmc.RegistrationFailureReason);

                // create a new xpanel room object and subscribe to its events
                xPanelUi = new XpanelForSmartGraphics(0x0b, this);
                xPanelUi.SigChange += xPanelUi_SigChange;
                xPanelUi.OnlineStatusChange += Device_OnlineStatusChange;

                // pathway to the SGD file for this ui project
                string xPanelSgdFilePath = string.Format("{0}\\Config.Standalone.sgd", Directory.GetApplicationDirectory());

                // make sure file exists in the application directory
                if (File.Exists(xPanelSgdFilePath))
                {
                    // load the SGD file for this ui project
                    xPanelUi.LoadSmartObjects(xPanelSgdFilePath);

                    // create reference for the various smart objects in the ui project
                    dmRmcOutputResList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcOutputResList];
                    dmRmcAspectModeList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcAspectList];
                    dmRmcUnderscanList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcUnderscanList];

                    // subscribe to the smart object sig events
                    dmRmcOutputResList.SigChange += dmRmcOutputResList_SigChange;
                    dmRmcAspectModeList.SigChange += dmRmcAspectModeList_SigChange;
                    dmRmcUnderscanList.SigChange += dmRmcUnderscanList_SigChange;
                }
                else
                {
                    ErrorLog.Error(">>> Could not find xpanel SGD file. SmartObjects will not work at this time");
                }

                // register device with the control system
                if (xPanelUi.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> xPanel has been registered successfully");
                else
                    ErrorLog.Error(">>> xPanel was not registered: {0}", xPanelUi.RegistrationFailureReason);
            }
            else
            {
                ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run");
            }

            // create a new timer object to track system inactivity or unplugged cables
            ShutdownTimer = new CTimer(ShutownTimerCallback, Timeout.Infinite, Timeout.Infinite);
        }
Пример #2
0
 void PulseOutput(ISwitchedOutput output, int pulseTime)
 {
     output.On();
     CTimer pulseTimer = new CTimer(new CTimerCallbackFunction((o) => output.Off()), pulseTime);
 }
 static int hbWebSocketClient_OnClose(WebSocketClient.WEBSOCKET_RESULT_CODES result, object o)
 {
     _hbWebSocketClientConnected       = false;
     _hbWebSocketClientConnectionCheck = new CTimer(hbWebSocketClient_CheckConnection, 3000);
     return(0);
 }
Пример #4
0
        void server_OnHttpRequest(object sender, OnHttpRequestArgs e)
        {
            try
            {
                if (e.Request.HasContentLength && e.Request.Path == "/:/timeline")
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(e.Request.ContentString);
                    XmlNodeList timelineList = doc.SelectNodes("MediaContainer/Timeline");

                    var currentType = "music";

                    foreach (XmlNode item in timelineList)
                    {
                        var type = item.Attributes["type"].Value;


                        if (item.Attributes["state"].Value == "playing")
                        {
                            foreach (var sectionItem in section)
                            {
                                var currentItem = currentlyPlaying;

                                if (sectionItem.Key == item.Attributes["key"].Value)
                                {
                                    currentlyPlaying = sectionItem;
                                    if (Currentlyplaying.Type == "movie" || Currentlyplaying.Type == "episode")
                                    {
                                        currentType = "video";
                                    }
                                    else if (Currentlyplaying.Type == "track")
                                    {
                                        currentType = "music";
                                    }

                                    if (!isPlaying || currentItem != currentlyPlaying)
                                    {
                                        isPlaying = true;
                                        Playing(true, "playing", Name);
                                    }
                                    break;
                                }
                            }
                        }
                        if (type == currentType)
                        {
                            if (item.Attributes["time"] != null)
                            {
                                PlayProgress(this, new PlayProgressEventArgs(Convert.ToInt64(item.Attributes["time"].Value) / 1000, Name));
                            }

                            if (item.Attributes["state"].Value == "paused")
                            {
                                isPlaying = false;
                                Playing(false, "paused", Name);
                            }
                            else if (item.Attributes["state"].Value == "stopped")
                            {
                                if (isPlaying)
                                {
                                    if (isPlayAll && section.Count > section.IndexOf(currentlyPlaying) + 1)
                                    {
                                        playNextItem = new CTimer(PlayNextItemCallback, this, 5000);
                                    }
                                    else if (isRepeatAll)
                                    {
                                        SelectItem(CurrentSection[0]);
                                    }
                                    else
                                    {
                                        isPlayAll = false;
                                    }

                                    isPlaying = false;
                                    PlayProgress(this, new PlayProgressEventArgs(Convert.ToInt64(currentlyPlaying.Duration) / 1000, Name));
                                    Playing(false, "stopped", Name);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Пример #5
0
        private void ParseDataReceived(string data)
        {
            try
            {
                if (_waitForConnection != null && !_isCommunicating)
                {
                    _waitForConnection.Stop();
                    _waitForConnection.Dispose();
                    _waitForConnection = null;

                    _isCommunicating = true;

                    if (onIsCommunicating != null)
                    {
                        onIsCommunicating(Convert.ToUInt16(_isCommunicating));
                    }

                    if (data.Contains("VERSION"))
                    {
                        var response = data.Split(':');
                        var ver      = response[1].Split(' ');

                        if (onVersion != null)
                        {
                            onVersion(ver[ver.Length - 1]);
                        }
                    }

                    SendData("STATUS LOAD");
                    SendData("STATUS SCENE");
                    SendData("STATUS OCCUPANCY");
                }

                if (_isCommunicating)
                {
                    var response = data.Split(':');

                    if (response[0] == "S")
                    {
                        if (response[1] == "ONLINE")
                        {
                            SendData("STATUS LOAD");
                            SendData("STATUS SCENE");
                        }
                        else if (response[1].Contains("SCENE"))
                        {
                            var scene = response[1].Split(' ');

                            _currentScene = Convert.ToInt16(scene[1]);

                            if (onSceneChange != null)
                            {
                                onSceneChange(Convert.ToUInt16(_currentScene));
                            }
                        }
                        else if (response[1].Contains("LOAD"))
                        {
                            var newLoad      = response[1].Split(' ');
                            var newLoadId    = newLoad[1];
                            var newLoadLevel = Convert.ToInt16(newLoad[2]);

                            foreach (var load in Loads)
                            {
                                if (load.Key.ID == newLoadId)
                                {
                                    load.Value.SendData(new LevelChangeEventArgs(newLoadLevel));
                                }
                            }
                        }
                        else if (response[1].Contains("OCCUPANCY"))
                        {
                            var occupancy = response[1].Split(' ');

                            if (occupancy[1] == "OCCUPIED")
                            {
                                _isOccupied = true;
                            }
                            else
                            {
                                _isOccupied = false;
                            }

                            if (onOccupancyChange != null)
                            {
                                onOccupancyChange(Convert.ToUInt16(_isOccupied));
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (_debug)
                {
                    ErrorLog.Exception("Exception occured in WattstopperDLM.Processor.DataReceived", e);
                }
            }
        }
Пример #6
0
        static void client_ConnectionStatus(int status, int id)
        {
            try
            {
                if (status == 2 && !IsConnected)
                {
                    if (debug == 1 || debug == 2)
                    {
                        ErrorLog.Notice("QsysProcessor is connected.");
                    }
                    IsConnected = true;
                    foreach (var item in SimplClients)
                    {
                        item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsConnected, "true", 1));
                    }

                    CrestronEnvironment.Sleep(1500);

                    //commandQueue.Enqueue(JsonConvert.SerializeObject(new GetComponents()));

                    AddComoponentToChangeGroup addComponent;


                    foreach (var item in Components)
                    {
                        addComponent                           = new AddComoponentToChangeGroup();
                        addComponent.method                    = "ChangeGroup.AddComponentControl";
                        addComponent.ComponentParams           = new AddComponentToChangeGroupParams();
                        addComponent.ComponentParams.Component = item.Key;
                        commandQueue.Enqueue(JsonConvert.SerializeObject(addComponent));
                    }

                    AddControlToChangeGroup addControl;

                    foreach (var item in Controls)
                    {
                        addControl                        = new AddControlToChangeGroup();
                        addControl.method                 = "ChangeGroup.AddControl";
                        addControl.ControlParams          = new AddControlToChangeGroupParams();
                        addControl.ControlParams.Controls = new List <string>();
                        addControl.ControlParams.Controls.Add(item.Key.Name);
                        commandQueue.Enqueue(JsonConvert.SerializeObject(addControl));
                    }

                    commandQueue.Enqueue(JsonConvert.SerializeObject(new CreateChangeGroup()));

                    if (heartbeatTimer != null)
                    {
                        heartbeatTimer.Stop();
                        heartbeatTimer.Dispose();
                    }

                    heartbeatTimer = new CTimer(SendHeartbeat, null, 0, 15000);

                    if (debug == 1 || debug == 2)
                    {
                        ErrorLog.Notice("QsysProcessor is initialized.");
                    }
                    isInitialized = true;

                    foreach (var item in SimplClients)
                    {
                        item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsRegistered, "true", 1));
                    }
                }
                else if (IsConnected && status != 2)
                {
                    if (debug == 1 || debug == 2)
                    {
                        ErrorLog.Error("QsysProcessor disconnected!");
                    }
                    IsConnected   = false;
                    isInitialized = false;
                    heartbeatTimer.Dispose();
                    foreach (var item in SimplClients)
                    {
                        item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsRegistered, "false", 0));
                        item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsConnected, "false", 0));
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
Пример #7
0
        private void ParseInternalResponse(string _returnString)
        {
            if (_returnString.Length > 0)
            {
                try
                {
                    JObject response = JObject.Parse(_returnString);
                    if (_returnString.Contains("Changes"))
                    {
                        IList <JToken>       changes       = response["params"]["Changes"].Children().ToList();
                        IList <ChangeResult> changeResults = new List <ChangeResult>();
                        foreach (JToken change in changes)
                        {
                            ChangeResult changeResult = JsonConvert.DeserializeObject <ChangeResult>(change.ToString());
                            if (changeResult.Component != null)
                            {
                                foreach (var item in this.Components)
                                {
                                    if (item.Key.Name == changeResult.Component)
                                    {
                                        item.Value.Fire(new QsysInternalEventsArgs(changeResult));
                                    }
                                }
                            }
                            else
                            {
                                foreach (var item in this.Controls)
                                {
                                    if (item.Key == changeResult.Name)
                                    {
                                        item.Value.Fire(new QsysInternalEventsArgs(changeResult));
                                    }
                                }
                            }
                        }
                    }
                    else if (_returnString.Contains("Properties"))
                    {
                        //IList<JToken> components = response["result"].Children().ToList();
                        //IList<ComponentResults> componentResults = new List<ComponentResults>();
                        //foreach (var component in components)
                        //{
                        //    ComponentResults result = JsonConvert.DeserializeObject<ComponentResults>(component.ToString());
                        //    if (result.Type == "gain")
                        //    {
                        //        foreach (var item in this.Components)
                        //        {
                        //            if (item.Key.Name == result.Name)
                        //            {
                        //                List<ComponentProperties> props = result.Properties.ToList();
                        //                ComponentProperties prop;
                        //                if ((prop = props.Find(x => x.Name == "max_gain")) != null)
                        //                {
                        //                    item.Value.Fire(new QsysInternalEventsArgs("max_gain", Convert.ToDouble(prop.Value), string.Empty));
                        //                }
                        //                if ((prop = props.Find(x => x.Name == "min_gain")) != null)
                        //                {
                        //                    item.Value.Fire(new QsysInternalEventsArgs("min_gain", Convert.ToDouble(prop.Value), string.Empty));
                        //                }
                        //            }
                        //        }
                        //    }
                        //}
                    }
                    else if (_returnString.Contains("EngineStatus") || _returnString.Contains("StatusGet"))
                    {
                        EngineStatusResult statusResult = JsonConvert.DeserializeObject <EngineStatusResult>(_returnString);
                        this.coreState    = (eCoreState)Enum.Parse(typeof(eCoreState), statusResult.Properties.State, true);
                        this.platform     = statusResult.Properties.Platform;
                        this.designName   = statusResult.Properties.DesignName;
                        this.designCode   = statusResult.Properties.DesignCode;
                        this.isRedundant  = Convert.ToBoolean(statusResult.Properties.IsRedundant);
                        this.isEmulator   = Convert.ToBoolean(statusResult.Properties.IsEmulator);
                        this.statusCode   = statusResult.Properties.Status.Code;
                        this.statusString = statusResult.Properties.Status.String;
                        foreach (var item in SimplClients)
                        {
                            item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.CoreState, "", (ushort)coreState));
                            item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.Platform, this.platform, 0));
                            item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.DesignName, designName, 0));
                            item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.DesignCode, designCode, 0));
                            item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsRedundant, Convert.ToString(isRedundant), (ushort)Convert.ToInt16(isRedundant)));
                            item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.IsEmulator, Convert.ToString(isEmulator), (ushort)Convert.ToInt16(isEmulator)));
                            item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.StatusCode, Convert.ToString(statusCode), (ushort)statusCode));
                            item.Value.Fire(new SimplEventArgs(eQscSimplEventIds.StatusString, statusString, 0));
                        }

                        if (!this.isInitialized)
                        {
                            this.CoreModuleInit();
                            this.SendCreateChangeGroup();
                        }
                    }
                    else if (_returnString.Contains("error"))
                    {
                        CoreError err = JsonConvert.DeserializeObject <CoreError>(_returnString);
                        this.SendDebug(String.Format("Core sent error: {0}:{1}", err.Error.Code, err.Error.Message));
                        switch (err.Error.Code)
                        {
                        case -32700:     //Parse error. Invalid JSON was received by the server.
                            break;

                        case -32600:     //Invalid request. The JSON sent is not a valid Request object.
                            break;

                        case -32601:     //Method not found.
                            break;

                        case -32602:     //Invalid params.
                            break;

                        case -32603:     //Server error.
                            break;

                        case 2:     //Invalid Page Request ID
                            break;

                        case 3:     //Bad Page Request - could not create the requested Page Request
                            break;

                        case 4:     //Missing file
                            break;

                        case 5:     //Change Groups exhausted
                            break;

                        case 6:     //Unknown change 6roup
                            this.SendCreateChangeGroup();
                            break;

                        case 7:     //Unknown component name
                            break;

                        case 8:     //Unknown control
                            break;

                        case 9:     //Illegal mixer channel index
                            break;

                        case 10:     //Login required
                            if (this.loginAttempt == false)
                            {
                                this.SendLogin();
                                this.loginAttempt = true;
                            }
                            else
                            {
                                this.SendDebug("The login attempt failed - check the username/pass to make sure its correct");
                                this.badLogin = true;
                            }
                            break;
                        }
                        this.SendDebug(string.Format("core error message - {0}-{1}", err.Error.Code, err.Error.Message));
                    }
                }
                catch (Exception e)
                {
                    this.SendDebug(String.Format("Parse internal error: \r\n--------MESSAGE---------\r\n{0}\r\n--------TRACE---------\r\n{1}\r\n--------ORIGINAL---------\r\n{2}\r\n---------------------\r\n", e.Message, e.StackTrace, _returnString));
                    this.responseQueueTimer = new CTimer(ResponseQueueDequeue, null, 0, 50);
                }
            }
        }
Пример #8
0
        //-------------------------------------//
        //    Function | DisablePoll
        // Description | ...
        //-------------------------------------//

        public void DisablePoll()
        {
            pollTimer.Stop();
            pollTimer = null;
        }
Пример #9
0
 public PinLockSubPage(PinLockSubPageParameters subPageParams)
     : base(subPageParams.Name, subPageParams.VisibilityJoin, subPageParams.TransitionJoin, new List <uint>(), subPageParams.BooleanOffset, subPageParams.AnalogOffset, subPageParams.SerialOffset)
 {
     _params             = subPageParams;
     _authShowErrorTimer = new CTimer(hideAuthError, Timeout.Infinite);
 }
 private void StartChecker()
 {
     checker = new CTimer(CheckerCallBack, null, 0, 60000);
     Debug("checker started");
 }
 /// <summary>生成と同時に開始する。</summary>
 public CCounter(int n開始値, int n終了値, double db間隔ms, CTimer timer)
     : this()
 {
     this.t開始(n開始値, n終了値, db間隔ms, timer);
 }
Пример #12
0
        public virtual void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            _initialized = true;

            _systemTimer = new CTimer(SystemTimerCallback, null, 1000, 1000);

            InternalClockInitialize();

            var response = string.Empty;

            CrestronConsole.SendControlSystemCommand("webport", ref response);
            var match = Regex.Match(response, @"Webserver port *= *(\d+)");

            if (match.Success)
            {
                var port = int.Parse(match.Groups[1].Value);
                Debug.WriteWarn("Built-web server is using port {0}", port);
            }

            foreach (var process in GetSystemItemsToInitialize())
            {
                _initializeQueue.Enqueue(process);
            }

            foreach (var source in Sources.Where(s => s.Device != null))
            {
                var device = source.Device as IInitializeComplete;
                if (device != null)
                {
                    _initializeQueue.Enqueue(new InitializeProcess(source.Device.Initialize,
                                                                   string.Format("Initializing Source Device: {0}", device.GetType().Name),
                                                                   TimeSpan.Zero, device.CheckInitializedOk));
                }
                else
                {
                    _initializeQueue.Enqueue(new InitializeProcess(source.Device.Initialize,
                                                                   string.Format("Initializing Source Device: {0}", source.Device.GetType().Name)));
                }
            }

            foreach (var room in Rooms)
            {
                _initializeQueue.Enqueue(new InitializeProcess(room.Initialize,
                                                               string.Format("Initializing Room: \"{0}\"", room.Name)));
            }

            var displays = Displays.Where(d => d.Device != null).ToArray();

            var count = 0;

            foreach (var display in displays)
            {
                count++;
                _initializeQueue.Enqueue(new InitializeProcess(display.Initialize,
                                                               string.Format("Initializing Display {0}", count)));
            }

            foreach (var room in Rooms.Where(r => r.FusionEnabled))
            {
                _initializeQueue.Enqueue(new InitializeProcess(room.FusionRegisterInternal,
                                                               string.Format("Registering Fusion for Room: \"{0}\"", room.Name), TimeSpan.FromSeconds(5)));
            }

            /*if (Rooms.Any(r => r.FusionEnabled))
             * {
             *  _initializeQueue.Enqueue(new InitializeProcess(FusionRVI.GenerateFileForAllFusionDevices,
             *      "Generating Fusion RVI file for discovery"));
             * }*/

            if (UIControllers.Any())
            {
                _initializeQueue.Enqueue(new InitializeProcess(UIControllers.ConnectToDefaultRooms,
                                                               "Setting up UI Controllers"));
            }

            if (UIControllers.Any())
            {
                _initializeQueue.Enqueue(new InitializeProcess(UIControllers.Initialize,
                                                               "Initializing UI Controllers"));
            }

            if (_systemThread != null)
            {
                return;
            }

            _systemThread = new Thread(SystemThreadProcess, null)
            {
                Name     = "UX.Lib2.SystemBase SystemThreadProcess()",
                Priority = Thread.eThreadPriority.LowestPriority
            };

            _systemStartupThread = new Thread(SystemStartupThreadProcess, null)
            {
                Name     = "System Startup Thread Process",
                Priority = Thread.eThreadPriority.MediumPriority
            };
        }
Пример #13
0
        private object SshCommsProcess(object userSpecific)
        {
            try
            {
                Thread.Sleep(1000);

                Debug.WriteInfo(string.Format("{0} attempting connection to {1}", GetType().Name, _address));

                var firstFail = false;

                while (!_client.IsConnected && _reconnect)
                {
                    try
                    {
                        ConnectionStatus = ClientStatus.AttemptingConnection;
                        _client.Connect();
                    }
                    catch
                    {
                        ConnectionStatus = ClientStatus.Disconnected;
                        if (!firstFail)
                        {
                            CloudLog.Warn("{0} could not connect to {1}, will retry every 30 seconds until connected",
                                          GetType().Name, _address);
                            firstFail = true;
                        }
                        Thread.Sleep(30000);
                    }
                }

                if (!_client.IsConnected && !_reconnect)
                {
                    _client.Dispose();
                    _client          = null;
                    ConnectionStatus = ClientStatus.Disconnected;
                    return(null);
                }

                CloudLog.Notice("{0} Connected to {1}", GetType().Name, _address);

                _shell = _client.CreateShellStream("terminal", 80, 24, 800, 600, BufferSize);

                var buffer    = new byte[BufferSize];
                var dataCount = 0;

                try
                {
                    while (_programRunning && _client.IsConnected)
                    {
                        while (_shell.CanRead && _shell.DataAvailable)
                        {
                            var incomingData      = new byte[BufferSize];
                            var incomingDataCount = _shell.Read(incomingData, 0, incomingData.Length);
#if DEBUG
                            _stopWatch.Start();
                            Debug.WriteSuccess("Tesira rx {0} bytes", incomingDataCount);
                            //Debug.WriteNormal(Debug.AnsiBlue +
                            //                  Tools.GetBytesAsReadableString(incomingData, 0, incomingDataCount, true) +
                            //                  Debug.AnsiReset);
#endif
                            if (!Connected &&
                                Encoding.ASCII.GetString(incomingData, 0, incomingDataCount)
                                .Contains("Welcome to the Tesira Text Protocol Server..."))
                            {
                                _requestsSent.Clear();
                                _requestsAwaiting.Clear();
                                _sendQueue.Enqueue("SESSION set verbose true");
                                ConnectionStatus = ClientStatus.Connected;
                                _keepAliveTimer  = new CTimer(specific =>
                                {
#if DEBUG
                                    Debug.WriteInfo(GetType().Name + " Sending KeepAlive");
#endif
                                    _client.SendKeepAlive();
                                }, null, KeepAliveTime, KeepAliveTime);
                            }
                            else if (Connected)
                            {
                                for (var i = 0; i < incomingDataCount; i++)
                                {
                                    buffer[dataCount] = incomingData[i];

                                    if (buffer[dataCount] == 10)
                                    {
                                        //skip
                                    }
                                    else if (buffer[dataCount] != 13)
                                    {
                                        dataCount++;
                                    }
                                    else
                                    {
                                        if (dataCount == 0)
                                        {
                                            continue;
                                        }

                                        var line = Encoding.UTF8.GetString(buffer, 0, dataCount);
                                        dataCount = 0;
#if DEBUG
                                        Debug.WriteSuccess("Tesira Rx Line", Debug.AnsiPurple + line + Debug.AnsiReset);
#endif
                                        TesiraMessage message = null;

                                        if (line == "+OK")
                                        {
                                            var request = _requestsAwaiting.TryToDequeue();
                                            if (request != null)
                                            {
#if DEBUG
                                                Debug.WriteInfo("Request Response Received", request);
                                                Debug.WriteSuccess(line);
#endif
                                                message = new TesiraResponse(request, null);
                                            }
                                        }
                                        else if (line.StartsWith("+OK "))
                                        {
                                            var request = _requestsAwaiting.TryToDequeue();
                                            if (request != null)
                                            {
#if DEBUG
                                                Debug.WriteInfo("Request Response Received", request);
                                                Debug.WriteSuccess(line);
#endif
                                                message = new TesiraResponse(request, line.Substring(4));
                                            }
                                        }
                                        else if (line.StartsWith("-ERR "))
                                        {
                                            var request = _requestsAwaiting.TryToDequeue();
                                            if (request != null)
                                            {
#if DEBUG
                                                Debug.WriteInfo("Request Response Received", request);
                                                Debug.WriteError(line);
#endif
                                                message = new TesiraErrorResponse(request, line.Substring(5));
                                            }
                                            else
                                            {
                                                Debug.WriteError("Error received and request queue returned null!");
                                                Debug.WriteError(line);
                                                Debug.WriteError("Clearing all queues!");
                                                _requestsSent.Clear();
                                                _requestsAwaiting.Clear();
                                            }
                                        }
                                        else if (line.StartsWith("! "))
                                        {
#if DEBUG
                                            Debug.WriteWarn("Notification Received");
                                            Debug.WriteWarn(line);
#endif
                                            message = new TesiraNotification(line.Substring(2));
                                        }
                                        else if (!_requestsSent.IsEmpty)
                                        {
                                            Debug.WriteWarn("Last sent request", _requestsSent.Peek());

                                            if (_requestsSent.Peek() == line)
                                            {
                                                _requestsAwaiting.Enqueue(_requestsSent.Dequeue());
#if DEBUG
                                                Debug.WriteNormal("Now awaiting for response for command", line);
#endif
                                            }
                                        }

                                        if (message != null && ReceivedData != null && message.Type != TesiraMessageType.ErrorResponse)
                                        {
                                            if (ReceivedData == null)
                                            {
                                                continue;
                                            }
                                            try
                                            {
                                                _timeOutCount = 0;

                                                ReceivedData(this, message);
                                            }
                                            catch (Exception e)
                                            {
                                                CloudLog.Exception(e, "Error calling event handler");
                                            }
                                        }
                                        else if (message != null && message.Type == TesiraMessageType.ErrorResponse)
                                        {
                                            _timeOutCount = 0;

                                            CloudLog.Error("Error message from Tesira: \"{0}\"", message.Message);
                                        }
                                    }
                                }
                            }
#if DEBUG
                            _stopWatch.Stop();
                            Debug.WriteNormal("Time to process: {0} ms", _stopWatch.ElapsedMilliseconds);
                            _stopWatch.Reset();
#endif
                            CrestronEnvironment.AllowOtherAppsToRun();
                        }

                        if (!_programRunning || !_client.IsConnected)
                        {
                            break;
                        }
#if DEBUG
                        //Debug.WriteNormal(Debug.AnsiBlue +
                        //                  string.Format(
                        //                      "Shell Can Write = {0}, _sendQueue = {1}, _requestsSent = {2}, _requestsAwaiting = {3}",
                        //                      _shell.CanWrite, _sendQueue.Count, _requestsSent.Count,
                        //                      _requestsAwaiting.Count) + Debug.AnsiReset);
#endif
                        if (_shell.CanWrite && !_sendQueue.IsEmpty && _requestsSent.IsEmpty && _requestsAwaiting.IsEmpty)
                        {
                            var s = _sendQueue.Dequeue();

                            if (_keepAliveTimer != null && !_keepAliveTimer.Disposed)
                            {
                                _keepAliveTimer.Reset(KeepAliveTime, KeepAliveTime);
                            }
#if DEBUG
                            Debug.WriteWarn("Tesira Tx", s);
#endif
                            _timeOutCount = 0;
                            _shell.WriteLine(s);
                            _requestsSent.Enqueue(s);
                            Thread.Sleep(20);
                        }
                        else if (!_requestsSent.IsEmpty || !_requestsAwaiting.IsEmpty)
                        {
                            _timeOutCount++;

                            if (_timeOutCount > 100)
                            {
                                CloudLog.Warn(
                                    "Error waiting to send requests in {0}, _requestsAwaiting.Count = {1}" +
                                    "and _requestsSent.Count = {2}. Clearing queues!",
                                    GetType().Name, _requestsAwaiting.Count, _requestsSent.Count);
                                _requestsAwaiting.Clear();
                                _requestsSent.Clear();
                                _timeOutCount = 0;
                            }

                            Thread.Sleep(20);
                        }
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Exception(e);
                }

                _loggedIn = false;

                if (_keepAliveTimer != null && !_keepAliveTimer.Disposed)
                {
                    _keepAliveTimer.Stop();
                    _keepAliveTimer.Dispose();
                    _keepAliveTimer = null;
                }

                if (_client != null && _client.IsConnected)
                {
                    _client.Dispose();
                    _client = null;
                }

                CloudLog.Notice("{0} Disconnected from {1}", GetType().Name, _address);
            }
            catch (Exception e)
            {
                CloudLog.Exception(e, "Error in {0}.SshCommsProcess()", GetType().Name);
            }

            ConnectionStatus = ClientStatus.Disconnected;

            if (!_reconnect || !_programRunning)
            {
                return(null);
            }

            Thread.Sleep(1000);

            CloudLog.Notice("Attempting reconnect to Tesira at {0}", _address);
            ConnectionStatus = ClientStatus.AttemptingConnection;

            Connect();

            return(null);
        }
Пример #14
0
 public void InitializeTimer(int lengthOfTime)
 {
     //Initialize timer with callback function and interval
     Timer = new CTimer(TimeHasElapsed, lengthOfTime);
 }
Пример #15
0
 private static CTimer NextTimer(CTimer timer)
 {
     return(CClassUtils.GetObjectField <CTimer>(timer, "next"));
 }
Пример #16
0
 public String_Pacer(int delay)
 {
     nDelay = delay;
     Timer  = new CTimer(OnTimer, this, delay, delay);
 }
Пример #17
0
        //-------------------------------------//
        //    Function | EnablePoll
        // Description | ...
        //-------------------------------------//

        public void EnablePoll()
        {
            pollTimer = new CTimer(pollTimerHandler, 2000);
        }
Пример #18
0
        /// <summary>
        /// Connect to the server, using the provided properties.
        /// </summary>
        public void Connect()
        {
            if (IsConnecting)
            {
                Debug.Console(0, this, "Connection attempt in progress.  Exiting Connect()");
                return;
            }

            IsConnecting   = true;
            ConnectEnabled = true;
            Debug.Console(1, this, "attempting connect");

            // Cancel reconnect if running.
            if (ReconnectTimer != null)
            {
                ReconnectTimer.Stop();
                ReconnectTimer = null;
            }

            // Don't try to connect if already
            if (IsConnected)
            {
                return;
            }

            // Don't go unless everything is here
            if (string.IsNullOrEmpty(Hostname) || Port < 1 || Port > 65535 ||
                Username == null || Password == null)
            {
                Debug.Console(1, this, "Connect failed.  Check hostname, port, username and password are set or not null");
                return;
            }

            // Cleanup the old client if it already exists
            if (Client != null)
            {
                Debug.Console(1, this, "Cleaning up disconnected client");
                Client.ErrorOccurred -= Client_ErrorOccurred;
                KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
            }

            // This handles both password and keyboard-interactive (like on OS-X, 'nixes)
            KeyboardInteractiveAuthenticationMethod kauth = new KeyboardInteractiveAuthenticationMethod(Username);

            kauth.AuthenticationPrompt += new EventHandler <AuthenticationPromptEventArgs>(kauth_AuthenticationPrompt);
            PasswordAuthenticationMethod pauth = new PasswordAuthenticationMethod(Username, Password);

            Debug.Console(1, this, "Creating new SshClient");
            ConnectionInfo connectionInfo = new ConnectionInfo(Hostname, Port, Username, pauth, kauth);

            Client = new SshClient(connectionInfo);

            Client.ErrorOccurred -= Client_ErrorOccurred;
            Client.ErrorOccurred += Client_ErrorOccurred;

            //Attempt to connect
            ClientStatus = SocketStatus.SOCKET_STATUS_WAITING;
            try
            {
                Client.Connect();
                TheStream = Client.CreateShellStream("PDTShell", 100, 80, 100, 200, 100000);
                TheStream.DataReceived += Stream_DataReceived;
                //TheStream.ErrorOccurred += TheStream_ErrorOccurred;
                Debug.Console(1, this, "Connected");
                ClientStatus = SocketStatus.SOCKET_STATUS_CONNECTED;
                IsConnecting = false;
                return; // Success will not pass here
            }
            catch (SshConnectionException e)
            {
                var ie = e.InnerException; // The details are inside!!
                if (ie is SocketException)
                {
                    Debug.Console(1, this, "'{0}' CONNECTION failure: Cannot reach host, ({1})", Key, ie.GetType());
                }
                else if (ie is System.Net.Sockets.SocketException)
                {
                    Debug.Console(1, this, "'{0}' Connection failure: Cannot reach host '{1}' on port {2}, ({3})",
                                  Key, Hostname, Port, ie.GetType());
                }
                else if (ie is SshAuthenticationException)
                {
                    Debug.Console(1, this, "Authentication failure for username '{0}', ({1})",
                                  Username, ie.GetType());
                }
                else
                {
                    Debug.Console(1, this, "Error on connect:\r({0})", e);
                }
            }
            catch (Exception e)
            {
                Debug.Console(1, this, "Unhandled exception on connect:\r({0})", e);
            }

            // Sucess will not make it this far
            ClientStatus = SocketStatus.SOCKET_STATUS_CONNECT_FAILED;
            HandleConnectionFailure();
        }
Пример #19
0
        protected virtual void OnReceive(string receivedString)
        {
            DeviceCommunicating = true;

            Debug.WriteInfo("VC RX", receivedString);

            if (_port != null)
            {
                if (_timeoutTimer == null || _timeoutTimer.Disposed)
                {
                    _timeoutTimer = new CTimer(specific =>
                    {
                        DeviceCommunicating = false;
                    }, 60000);
                }
                else
                {
                    _timeoutTimer.Reset(60000);
                }
            }
#if DEBUG
            Debug.WriteNormal(Debug.AnsiPurple + "Codec Rx", Debug.AnsiReset + receivedString);
#endif
            if (receivedString.Contains("Password:"******"vcbutton play")
            {
                ContentPlaying = ContentPlayingMode.PlayingNear;
                return;
            }

            if (receivedString == "vcbutton stop")
            {
                ContentPlaying = ContentPlayingMode.Stopped;
                return;
            }

            if (receivedString == "systemsetting selfview On")
            {
                _selfView = true;
                return;
            }

            if (receivedString == "systemsetting selfview Off")
            {
                _selfView = false;
                return;
            }

            if (receivedString == "videomute near on")
            {
                _videoMute = true;
                if (VideoMuteChange != null)
                {
                    VideoMuteChange(true);
                }
                return;
            }

            if (receivedString == "videomute near off")
            {
                _videoMute = false;
                if (VideoMuteChange != null)
                {
                    VideoMuteChange(false);
                }
                return;
            }

            if (receivedString.StartsWith("Control event: "))
            {
                if (receivedString.Contains("vcbutton play"))
                {
                    ContentPlaying = ContentPlayingMode.PlayingNear;
                }
                else if (receivedString.Contains("vcbutton stop"))
                {
                    ContentPlaying = ContentPlayingMode.Stopped;
                }
                else if (receivedString.Contains("vcbutton farplay"))
                {
                    ContentPlaying = ContentPlayingMode.PlayingFar;
                }
                else if (receivedString.Contains("vcbutton farstop"))
                {
                    ContentPlaying = ContentPlayingMode.Stopped;
                }
                return;
            }

            switch (receivedString)
            {
            case "wake":
                IsSleeping = false;
                Send("preset near go 0");
                return;

            case "popupinfo: question: The system is going to sleep.":
            case "sleep":
                IsSleeping = true;
                return;

            case "popupinfo: question: The call has ended.":
                if (Calls.InProgressCalls.Any())
                {
                    Send("callinfo all");
                }
                return;
            }

            if (receivedString.Contains("Here is what I know about myself:"))
            {
                RegisterFeedback();
            }

            OnReceivedFeedback(this, receivedString);
        }
Пример #20
0
 public void Pulse(int time)
 {
     Close();
     _pulseTimer = new CTimer(specific => Open(), time);
 }
Пример #21
0
        void client_ConnectionStatus(int status, int id)
        {
            try
            {
                if (status == 2 && !IsConnected)
                {
                    IsConnected = true;

                    if (debug == 1 || debug == 2)
                    {
                        ErrorLog.Notice("QsysProcessor is connected.");
                    }

                    if (onIsConnected != null)
                    {
                        onIsConnected(1);
                    }
                }
                else if (IsConnected && status != 2)
                {
                    if (debug == 1 || debug == 2)
                    {
                        ErrorLog.Error("QsysProcessor disconnected!");
                    }

                    client.Disconnect();

                    reconnectionWait = new CTimer(StartConnectionAgain, 30000);

                    isLoggedIn    = false;
                    IsConnected   = false;
                    isInitialized = false;

                    if (heartbeatTimer != null)
                    {
                        heartbeatTimer.Dispose();
                    }

                    if (onIsRegistered != null)
                    {
                        onIsRegistered(0);
                    }

                    if (onIsLoggedIn != null)
                    {
                        onIsLoggedIn(0);
                    }

                    if (onIsConnected != null)
                    {
                        onIsConnected(0);
                    }
                }
            }
            catch (Exception e)
            {
                if (debug == 1 || debug == 2)
                {
                    ErrorLog.Error("Error in QsysProcessor client_ConnectionStatus: {0}", e.Message);
                }
            }
        }
Пример #22
0
        //-------------------------------------//
        //      Method | StartScheduler
        // Description | ...
        //-------------------------------------//
        private static void StartScheduler()
        {
            sTimer = new CTimer(Tick, null, tickTime, tickTime);

            DebugMessage("[DEBUG] EasyMode Scheduler started.");
        }
Пример #23
0
        /// <summary>
        /// Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name.
        /// </summary>
        public void Connect()
        {
            ConnectionCount++;
            Debug.Console(2, this, "Attempting connect Count:{0}", ConnectionCount);


            if (IsConnected)
            {
                Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Already connected. Ignoring.");
                return;
            }
            if (IsTryingToConnect)
            {
                Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Already trying to connect. Ignoring.");
                return;
            }
            try
            {
                IsTryingToConnect = true;
                if (RetryTimer != null)
                {
                    RetryTimer.Stop();
                    RetryTimer = null;
                }
                if (string.IsNullOrEmpty(Hostname))
                {
                    Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "DynamicTcpClient: No address set");
                    return;
                }
                if (Port < 1 || Port > 65535)
                {
                    Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "DynamicTcpClient: Invalid port");
                    return;
                }
                if (string.IsNullOrEmpty(SharedKey) && SharedKeyRequired)
                {
                    Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "DynamicTcpClient: No Shared Key set");
                    return;
                }

                // clean up previous client
                if (Client != null)
                {
                    Cleanup();
                }
                DisconnectCalledByUser = false;

                Client = new SecureTCPClient(Hostname, Port, BufferSize);
                Client.SocketStatusChange += Client_SocketStatusChange;
                if (HeartbeatEnabled)
                {
                    Client.SocketSendOrReceiveTimeOutInMs = (HeartbeatInterval * 5);
                }
                Client.AddressClientConnectedTo = Hostname;
                Client.PortNumber = Port;
                // SecureClient = c;

                //var timeOfConnect = DateTime.Now.ToString("HH:mm:ss.fff");

                ConnectFailTimer = new CTimer(o =>
                {
                    Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Connect attempt has not finished after 30sec Count:{0}", ConnectionCount);
                    if (IsTryingToConnect)
                    {
                        IsTryingToConnect = false;

                        //if (ConnectionHasHungCallback != null)
                        //{
                        //    ConnectionHasHungCallback();
                        //}
                        //SecureClient.DisconnectFromServer();
                        //CheckClosedAndTryReconnect();
                    }
                }, 30000);

                Debug.Console(2, this, "Making Connection Count:{0}", ConnectionCount);
                Client.ConnectToServerAsync(o =>
                {
                    Debug.Console(2, this, "ConnectToServerAsync Count:{0} Ran!", ConnectionCount);

                    if (ConnectFailTimer != null)
                    {
                        ConnectFailTimer.Stop();
                    }
                    IsTryingToConnect = false;

                    if (o.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED)
                    {
                        Debug.Console(2, this, "Client connected to {0} on port {1}", o.AddressClientConnectedTo, o.LocalPortNumberOfClient);
                        o.ReceiveDataAsync(Receive);

                        if (SharedKeyRequired)
                        {
                            WaitingForSharedKeyResponse = true;
                            WaitForSharedKey            = new CTimer(timer =>
                            {
                                Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Shared key exchange timer expired. IsReadyForCommunication={0}", IsReadyForCommunication);
                                // Debug.Console(1, this, "Connect attempt failed {0}", c.ClientStatus);
                                // This is the only case where we should call DisconectFromServer...Event handeler will trigger the cleanup
                                o.DisconnectFromServer();
                                //CheckClosedAndTryReconnect();
                                //OnClientReadyForcommunications(false); // Should send false event
                            }, 15000);
                        }
                        else
                        {
                            //CLient connected and shared key is not required so just raise the ready for communication event. if Shared key
                            //required this is called by the shared key being negotiated
                            if (IsReadyForCommunication == false)
                            {
                                OnClientReadyForcommunications(true); // Key not required
                            }
                        }
                    }
                    else
                    {
                        Debug.Console(1, this, "Connect attempt failed {0}", o.ClientStatus);
                        CheckClosedAndTryReconnect();
                    }
                });
            }
            catch (Exception ex)
            {
                Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Client connection exception: {0}", ex.Message);
                IsTryingToConnect = false;
                CheckClosedAndTryReconnect();
            }
        }
Пример #24
0
        public CodecScheduleAwareness()
        {
            Meetings = new List <Meeting>();

            ScheduleChecker = new CTimer(CheckSchedule, null, 1000, 1000);
        }
Пример #25
0
    public static int UpdateTimerList(CTimerList In_cTimerL)
    {
        int    nMin_Sec   = Int32.MaxValue; // 最紧迫的timer 运行
        CTimer cMin_Timer = null;

        int nStartMSec = System.DateTimeOffset.Now.Millisecond;

        for (int i = 0; i < In_cTimerL.ArrayTimerList.Length; i++)
        {
            if (In_cTimerL.ArrayTimerList[i].CHashNextTimer.Equals(null))
            {
                break;
            }
            CTimer tmpTimer = In_cTimerL.ArrayTimerList[i].CHashNextTimer;

            for ( ; tmpTimer != null;)
            {
                int nCurTime = System.DateTimeOffset.Now.Millisecond; // 获取当前时间

                if (tmpTimer.NEndTimeStamp <= nCurTime)               // 需要触发回调函数
                {
                    if (tmpTimer.On_Timer != null)                    // 需要触发回调函数
                    {
                        if (tmpTimer.Data == null && tmpTimer.Data2 == null)
                        {
                            tmpTimer.On_Timer();
                        }

                        if (tmpTimer.NRepeatTime > 0)
                        {
                            tmpTimer.NRepeatTime--;
                            if (tmpTimer.NRepeatTime == 0)
                            {
                                CTimer tmpTimer2 = tmpTimer;
                                tmpTimer = tmpTimer.CHashNextTimer;
                                tmpTimer2.Release();
                            }
                            else
                            {
                                tmpTimer.NEndTimeStamp = System.DateTimeOffset.Now.Millisecond + tmpTimer.NDuration;

                                if ((tmpTimer.NEndTimeStamp - nStartMSec) < nMin_Sec)
                                {
                                    cMin_Timer = tmpTimer;
                                    nMin_Sec   = tmpTimer.NEndTimeStamp - nStartMSec;
                                }

                                tmpTimer = tmpTimer.CHashNextTimer;
                            }
                        }
                        else
                        {
                            tmpTimer.NEndTimeStamp = System.DateTimeOffset.Now.Millisecond + tmpTimer.NDuration;

                            if ((tmpTimer.NEndTimeStamp - nStartMSec) < nMin_Sec)
                            {
                                cMin_Timer = tmpTimer;
                                nMin_Sec   = tmpTimer.NEndTimeStamp - nStartMSec;
                            }

                            tmpTimer = tmpTimer.CHashNextTimer;
                        }
                    }
                    else //不需要触发的时候
                    {
                        if ((tmpTimer.NEndTimeStamp - nStartMSec) < nMin_Sec)
                        {
                            cMin_Timer = tmpTimer;
                            nMin_Sec   = tmpTimer.NEndTimeStamp - nStartMSec;
                        }

                        tmpTimer = tmpTimer.CHashNextTimer;
                    }
                }
            }
        }
        if (cMin_Timer != null) // 存在一个时间紧迫的timer
        {
            return(cMin_Timer.NEndTimeStamp - System.DateTimeOffset.Now.Millisecond);
        }
        return(-1);
    }
Пример #26
0
 public OpenChestState(StateMachine sm) : base(sm)
 {
     timer = new CTimer();
     timer.IntervalSeconds = TIME_OPEN_CHEST_AFTER_UNSELECTED;
 }
Пример #27
0
        public PlexClient(string ipAddress, int playerPort, int listenPort, string name)
        {
            PlexClientInfo info = new PlexClientInfo(ipAddress, playerPort, listenPort, name);

            serverStatus = new CTimer(ServerStatus, info, 0, 10000);
        }
Пример #28
0
 // Use this for initialization
 void Start()
 {
     CTimer.Start(2f).SetOnComplete(ChangeColor).SetUpdateMode(UpdateMode.Normal);
 }
Пример #29
0
        //-------------------------------------//
        //    Function | clientConnect
        // Description | Handler for TCP client connect event. Begins listening for incoming
        //               data from server, and starts timer for polling
        //-------------------------------------//

        internal static void clientConnect(TCPClient _cli)
        {
            client.ReceiveDataAsync(clientDataRX);
            pollTimer = new CTimer(pollTimerHandler, 2000);
        }
Пример #30
0
 /// <summary>
 /// Entry point for the program
 /// </summary>
 public override void InitializeSystem()
 {
     _startTimer = new CTimer(StartSystem, StartupTime);
 }
Пример #31
0
        //-------------------------------------//
        //    Function | pollTimerHandler
        // Description | Requests access logs and resets timer
        //-------------------------------------//

        internal void pollTimerHandler(object o)
        {
            RequestLogs(targetAddress, targetUserName, targetPassword, false, false);
            pollTimer = new CTimer(pollTimerHandler, 2000);
        }
Пример #32
0
 public GoogleNestDevice()
 {
     //Setup fan timer
     fanTimer = new CTimer(FanTimerCompleted, 1000);
     fanTimer.Stop();
 }