Exemple #1
0
        public void CliDriver_ConstructorWorks()
        {
            CliDriver drv  = new CliDriver();
            long      tfms = drv.targetFrameMs;

            Assert.That(drv, Is.Not.Null);
            Assert.That(tfms, Is.EqualTo(250)); // FIXME - this is a silly and fragile test
        }
Exemple #2
0
        public void CliDriver_ConstructorWorks()
        {
            CliDriver drv  = new CliDriver();
            long      tfms = drv.targetFrameMs;

            Assert.That(drv, Is.Not.Null);
            Assert.That(tfms, Is.EqualTo(16)); // default val
        }
        public void SendData(string sata)
        {
            if (this.Status != ConnStatus.Opened)
            {
                throw new Exception($"连接池状态异常Status={this.Status}");
            }
            CliDriver.SetStandardInput(sata);
            _DataFrameManager.PushCmdKey(sata);
            var rtnMst = _DataFrameManager.GetResponse(sata);


            IOHelper.WriteLine(rtnMst.ToString(), ConsoleColor.Red);
        }
        private bool disposedValue = false; // 要检测冗余调用

        protected virtual void Dispose(bool disposing)
        {
            this.Status = ConnStatus.Closed;
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: 释放托管状态(托管对象)。
                    CliDriver.Dispose();
                    this.Status = ConnStatus.Disposed;
                }

                // TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器。
                // TODO: 将大型字段设置为 null。

                disposedValue = true;
            }
        }
        public ConnStatus Open(Action <string> reciveOnlineData, string args = null)
        {
            _DataFrameManager = new DataFrameManager();
            this.Status       = ConnStatus.Opening;
            if (CliDriver == null)
            {
                CliDriver = Cli.Wrap(ConnectionStr, args);
            }
            this._DataFrameManager.Start();
            CliDriver.ListenAsync();

            CliDriver.SetStandardOutputCallback((msg) =>
            {
                if (_DataFrameManager != null)
                {
                    _DataFrameManager.Push(new DataFrameStr(msg));
                }
                if (reciveOnlineData != null)
                {
                    reciveOnlineData.Invoke(msg);
                }
                if (this.Status == ConnStatus.Opening)
                {
                    this.Status = ConnStatus.Opened;
                    this._ConnectionMREvent.Set();
                }
            });
            CliDriver.SetStandardErrorCallback((msg) =>
            {
                //  this.Dispose();
                //  throw new Exception(msg);
            });
            CliDriver.SetStandardErrorClosedCallback(() =>
            {
                this.Dispose();
            });
            _ConnectionMREvent.WaitOne(TimeSpan.FromSeconds(180));
            return(this.Status);
        }