示例#1
0
        public void Add(DisposableObject instance)
        {
            Stopwatch countTime = new Stopwatch();

            countTime.Start();
            repository.TryAdd(instance.Id, instance);
            countTime.Stop();
            ExecutionTimes.Add(countTime.Elapsed);
            // Console.WriteLine($"Add lock took: {countTime.Elapsed}");
        }
        //-------------------------------------------------------------------------------------------------//

        public DriverGeneric(XmlNode xmlNodeEquipmentConfig, ExperimentSpecification specification)
        {
            const string STRLOG_MethodName = "DriverGeneric";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Initialise static variables
            //
            if (DriverGeneric.firstInstance == true)
            {
                DriverGeneric.initialised   = false;
                DriverGeneric.online        = false;
                DriverGeneric.statusMessage = STRLOG_NotInitialised;
                DriverGeneric.firstInstance = false;
            }

            //
            // Initialise local variables
            //
            this.xmlNodeEquipmentConfig = xmlNodeEquipmentConfig;
            this.specification          = specification;
            this.lastError             = null;
            this.running               = false;
            this.executionStatus       = ExecutionStatus.None;
            this.executionResultStatus = ExecutionStatus.None;

            //
            // Initialise execution times for this driver, won't used when overridden
            //
            this.executionTimes = new ExecutionTimes {
                initialise = 3, start = 5, run = 7, stop = 4, finalise = 2
            };

            try
            {
                //
                // Create thread objects
                //
                if ((this.signalRunning = new Object()) == null)
                {
                    throw new ArgumentNullException(STRERR_signalRunning);
                }
            }
            catch (Exception ex)
            {
                // Log the message and throw the exception back to the caller
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
示例#3
0
        public void Remove(string id)
        {
            Stopwatch countTime = new Stopwatch();

            countTime.Start();

            repository.TryRemove(id, out var removed);

            countTime.Stop();
            ExecutionTimes.Add(countTime.Elapsed);
            // Console.WriteLine($"Remove lock took: {countTime.Elapsed}");
        }
示例#4
0
        public void Remove(string id)
        {
            Stopwatch countTime = new Stopwatch();

            countTime.Start();
            lock (lockObj)
            {
                //  Console.WriteLine($"Remove lock took: {countTime.Elapsed}");
                repository.Remove(id);
                countTime.Stop();
            }
            ExecutionTimes.Add(countTime.Elapsed);
        }
示例#5
0
        public void Clear()
        {
            Stopwatch countTime = new Stopwatch();

            countTime.Start();

            foreach (var item in repository)
            {
                item.Value.Dispose();
            }
            countTime.Stop();
            ExecutionTimes.Add(countTime.Elapsed);

            repository.Clear();
        }
示例#6
0
        public void Clear()
        {
            Stopwatch countTime = new Stopwatch();

            countTime.Start();
            lock (lockObj)
            {
                foreach (var item in repository.Values)
                {
                    item.Dispose();
                }
                repository.Clear();
                countTime.Stop();
                ExecutionTimes.Add(countTime.Elapsed);
            }
        }
        //-------------------------------------------------------------------------------------------------//
        public DriverGeneric(XmlNode xmlNodeEquipmentConfig, ExperimentSpecification specification)
        {
            const string STRLOG_MethodName = "DriverGeneric";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Initialise static variables
            //
            if (DriverGeneric.firstInstance == true)
            {
                DriverGeneric.initialised = false;
                DriverGeneric.online = false;
                DriverGeneric.statusMessage = STRLOG_NotInitialised;
                DriverGeneric.firstInstance = false;
            }

            //
            // Initialise local variables
            //
            this.xmlNodeEquipmentConfig = xmlNodeEquipmentConfig;
            this.specification = specification;
            this.lastError = null;
            this.running = false;
            this.executionStatus = ExecutionStatus.None;
            this.executionResultStatus = ExecutionStatus.None;

            //
            // Initialise execution times for this driver, won't used when overridden
            //
            this.executionTimes = new ExecutionTimes { initialise = 3, start = 5, run = 7, stop = 4, finalise = 2 };

            try
            {
                //
                // Create thread objects
                //
                if ((this.signalRunning = new Object()) == null)
                {
                    throw new ArgumentNullException(STRERR_signalRunning);
                }
            }
            catch (Exception ex)
            {
                // Log the message and throw the exception back to the caller
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }