Пример #1
0
        public DataTable ExportStateOnItemChangeToDataTable(string keyItem)
        {
            //find all changes at the keyItem
            //Create an array with all parameter names in it
            //Create an array of List where the array index match the parameter name
            //and list index match the parameter value at the keyItem change
            LogRowData[] keyItemRows = GetItemRows(keyItem);
            string[]     itemIDs     = GetItemsIDs().Where(p => p != keyItem).ToArray();
            var          result      = new string[keyItemRows.Length, itemIDs.Length];

            for (var item = 0; item < itemIDs.Length; item++)
            {
                LogRowData[] allData      = GetItemRows(itemIDs[item]);
                var          allDataIndex = 0;
                int          maxIndex     = allData.Length;
                for (var i = 0; i < keyItemRows.Length; i++)
                {
                    long timeStamp = keyItemRows[i].CycleIndex;
                    while (allDataIndex < maxIndex && allData[allDataIndex].CycleIndex < timeStamp)
                    {
                        allDataIndex++;
                    }

                    LogRowData lastItem = allData[Math.Min(allDataIndex, maxIndex - 1)];
                    result[i, item] = lastItem.Value;
                }
            }

            //Save to csv
            var table = new DataTable();

            table.Columns.Add(keyItem, typeof(string));
            foreach (string itemID in itemIDs)
            {
                table.Columns.Add(itemID, typeof(string));
            }

            for (var i = 0; i < result.GetLength(0); i++)
            {
                var row = new object[result.GetLength(1) + 1];
                row[0] = keyItemRows[i].Value;
                for (var j = 0; j < row.Length - 1; j++)
                {
                    row[j + 1] = result[i, j];
                }

                table.Rows.Add(row);
            }

            return(table);
        }
Пример #2
0
        /// <summary>
        /// Get start time of build.
        /// </summary>
        /// <param name="database"></param>
        /// <returns></returns>
        /// <remarks>
        /// Returns the first occurance of one of the following:
        /// 1. Play is pressed
        /// 2. ProcessManagerState is Running
        /// 3. InternalProcessManagerState is Running
        /// 4. Temperature has a logged value above 600 deg.
        /// </remarks>
        public static DateTime GetBuildStart(IItemDatabase database)
        {
            LogRowData startProcess                = database.GetFirstItem("Process.ProcessManager.StartProcess", x => x.Value == "True");
            LogRowData processmanagerState         = database.GetFirstItem("Process.ProcessManager.ProcessManagerState", x => x.Value == "Running");
            LogRowData internalProcessmanagerState = database.GetFirstItem("Process.ProcessManager.InternalProcessManagerState", x => x.Value == "Running");

            if (startProcess == null && processmanagerState == null && internalProcessmanagerState == null)
            {
                throw new ApplicationException("Start of process not found.");
            }

            List <LogRowData> data = new List <LogRowData>()
            {
                startProcess, processmanagerState, internalProcessmanagerState
            };
            DateTime result = data.Where(t => t != null).Min(p => p.TimeStamp);

            return(result);
        }
Пример #3
0
        public IEnumerable <LogRowData> GetData(IEnumerable <LogRowIndex> indexes)
        {
            foreach (LogRowIndex logRowIndex in indexes)
            {
                WeakReference reference;

                if (!m_DataCache.TryGetValue(logRowIndex.RowStart, out reference))
                {
                    reference = new WeakReference(null);
                    m_DataCache.Add(logRowIndex.RowStart, reference);
                }

                LogRowData data = reference.Target as LogRowData;

                //Reload data point
                if (data == null)
                {
                    data             = LogRowDataFactory.CreateData(m_Stream, logRowIndex);
                    reference.Target = data;
                }

                yield return(data);
            }
        }
Пример #4
0
 public LogRowDataPoint(LogRowData data, IFormatProvider formatProvider)
 {
     TimeStamp = data.TimeStamp;
     Value     = double.Parse(data.Value, formatProvider);
 }