Ejemplo n.º 1
0
        public bool GetDataWriterData(List <string> signalNames, DateTime lasttime, out List <Signal> signals, out DateTime stime)
        {
            signals = new List <Signal>();
            stime   = StartTimeStamps.Find(x => x > lasttime);
            if (stime != DateTime.MinValue)
            {
#if DEBUG
                Console.WriteLine("start time stamp in GetDataWriterData: " + stime.ToString("yyyyMMdd_HHmmss"));
                Console.WriteLine("number of timestamps in StartTimeStamps: " + StartTimeStamps.Count());
#endif
                DateTime etime;
                if (TimePairs.TryGetValue(stime, out etime))
                {
                    lock (_theInputSignalsLock)
                    {
                        foreach (var name in signalNames)
                        {
                            if (Signals.TryGetValue(name, out Dictionary <DateTime, Signal> sdict))
                            {
                                if (sdict.TryGetValue(etime, out Signal sig))
                                {
                                    signals.Add(sig);
                                }
                            }
                        }
                    }
                }
                if (signals.Count == signalNames.Count)
                {
                    lock (_theDataWriterLock)
                    {
                        if (_doneDataWriterFlags.TryGetValue(etime, out List <bool> list))
                        {
                            list.Add(true);
                            if (list.Count == NumberOfDataWriters)
                            {
                                _doneDataWriterFlags.Remove(etime);
                                TimePairs.Remove(stime);
                                StartTimeStamps.Remove(stime);
                            }
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }