コード例 #1
0
        protected override void Dispose(MosaicLib.Utils.DisposableBase.DisposeType disposeType)
        {
            if (disposeType == DisposeType.CalledExplicitly)
                Utils.Fcns.DisposeOfObject(ref sp);

            spFlushAction = null;
        }
コード例 #2
0
        public BusMaster(string name, string targetSpecStr, bool autoConnect)
            : base(name, "HART.BusMaster")
        {
            portConfig = new SerialIO.PortConfig(name + ".sp", targetSpecStr, MosaicLib.SerialIO.LineTerm.None)
            {
                EnableAutoReconnect = autoConnect,
                // SpinWaitTimeLimit = TimeSpan.FromSeconds(0.001),
                TraceDataLoggerGroupID = Logging.LookupDistributionGroupName,       // support mapping of this logger into a non-default group.
                TraceDataMesgType = Logging.MesgType.Trace,
                TraceMesgType = Logging.MesgType.Trace,
                DebugMesgType = Logging.MesgType.Trace,
            };

            try
            {
                sp = SerialIO.Factory.CreatePort(portConfig);
            }
            catch (System.Exception ex)
            {
                Log.Error.Emit("CreatePort failed: {0}", ex.Message);
                sp = SerialIO.Factory.CreatePort(new MosaicLib.SerialIO.PortConfig(name + ".sp", "<NullPort/>", MosaicLib.SerialIO.LineTerm.None));
            }

            spFlushAction = sp.CreateFlushAction(TimeSpan.FromSeconds(0.100));
        }