Beispiel #1
0
        public async Task Start()
        {
            if (State.IsOn)
            {
                await State.Ready("on");

                return;
            }
            _readyState.IsOff = true;
            if (_lifeTimer != null)
            {
                throw new InvalidOperationException("start life timer exist");
            }

            State.IsOn = EventEmitter.State.PendingSymbol;

            try
            {
                if (_memory == null)
                {
                    _memory = new MemoryCard(_options.Name, _loggerFactory.CreateLogger <MemoryCard>(), _loggerFactory);
                }
                try
                {
                    await _memory.Load();
                }
                catch (Exception exception)
                {
                    _logger.LogError(exception, "start memory load failed.");
                }
                await InitPuppet();

                await Puppet.Start();

                InitPuppetEventBridge(Puppet);
                //TODO: IO component
                if (!string.IsNullOrWhiteSpace(_options.IoToken))
                {
                }
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, "start failed.");
                EmitError(exception);
                try
                {
                    await Stop();
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "start stop failed.");
                    EmitError(e);
                }
            }
            OnHeartbeat((data) => MemoryCheck());

            _readyState.IsOn = true;
            EmitStart();
        }
Beispiel #2
0
        public async Task Reset()
        {
            await Puppet.Stop();

            await Puppet.Start();
        }