Beispiel #1
0
        public void LogFile_In_add(List <LogFile_In_rec> _LogFile_In_table, string _inString)
        {
            LogFile_In_rec newRec = new LogFile_In_rec();

            newRec.machStat = new List <bool>();
            newRec.stringIn = _inString;

            newRec.timeInStr = LeftStr(_inString, 19);

            string noTimeStr = RightStr(_inString, _inString.Length - 20);

            //Console.WriteLine("orig = " + _inString);
            //Console.WriteLine("strip= " + noTimeStr);
            for (int i = 1; i <= NumMachines; i++)
            {
                string testStr = i.ToString().Trim();
                if (noTimeStr.Contains(testStr))
                {
                    newRec.machStat.Add(true);
                }
                else
                {
                    newRec.machStat.Add(false);
                };
            }
            ;

            _LogFile_In_table.Add(newRec);
        }
Beispiel #2
0
        public void Disp_LogInfo_add(
            LogFile_In_rec _logFileRec,
            List <Disp_LogInfo_rec> _DispLogInfo_table
            )
        {
            //add record to display table
            Disp_LogInfo_rec newDispRec = new Disp_LogInfo_rec();

            newDispRec.timeStr = _logFileRec.timeInStr;
            for (int i = 0; i < 9; i++)
            {
                string outStr = "    ";
                if (_logFileRec.machStat[i])
                {
                    outStr = "on";
                }
                switch (i)
                {
                case 0:
                    newDispRec.mach_01 = outStr;
                    break;

                case 1:
                    newDispRec.mach_02 = outStr;
                    break;

                case 2:
                    newDispRec.mach_03 = outStr;
                    break;

                case 3:
                    newDispRec.mach_04 = outStr;
                    break;

                case 4:
                    newDispRec.mach_05 = outStr;
                    break;

                case 5:
                    newDispRec.mach_06 = outStr;
                    break;

                case 6:
                    newDispRec.mach_07 = outStr;
                    break;

                case 7:
                    newDispRec.mach_08 = outStr;
                    break;

                case 8:
                    newDispRec.mach_09 = outStr;
                    break;
                }
                ;
            }
            _DispLogInfo_table.Add(newDispRec);
        }
Beispiel #3
0
        public void Disp_LogInfo_load(
            List <LogFile_In_rec> _LogFile_In_table,
            List <Disp_LogInfo_rec> _DispLogInfo_table,
            List <LogEvents_rec> _LogEvents_table,
            List <Disp_LogEvents_rec> _Disp_LogEvents_table
            )
        {
            //load all of the data into disp table
            //this routine is for all the Log data even if there were no changes
            //_DispLogInfo_table = new List<Disp_LogInfo_rec>();

            _DispLogInfo_table.Clear();

            //store the first record automatically
            if (_LogFile_In_table.Count() > 0)
            {
                //used to store prev log, now it does not matter
            }
            ;
            if (_LogFile_In_table.Count() > 1) //more than one record
            {
                //there is more than one record, so loop thru all
                for (int i = 0; i < _LogFile_In_table.Count(); i++)
                {
                    //first step is to load all of the log data as it came in
                    Disp_LogInfo_add(_LogFile_In_table[i], _DispLogInfo_table);
                }
                ;
            }
            ;
            Console.WriteLine("End of log info");

            //load the log Events
            //make as a separate function later on
            LogFile_In_rec prevLogRec = new LogFile_In_rec();
            LogFile_In_rec newLogRec  = new LogFile_In_rec();

            if (_LogFile_In_table.Count() > 0)
            {
                prevLogRec.timeInStr = _LogFile_In_table[0].timeInStr;
                prevLogRec.machStat  = new List <bool>();
                for (int j = 0; j < NumMachines; j++)
                {
                    prevLogRec.machStat.Add(_LogFile_In_table[0].machStat[j]);
                }
                ;

                //add a record to the events display table with the first record
            }
            ;

            if (_LogFile_In_table.Count() > 1) //more than one record
            {
                //there is more than one record, so loop thru all
                for (int i = 0; i < _LogFile_In_table.Count(); i++)
                {
                    newLogRec.timeInStr = "";
                    newLogRec.machStat  = new List <bool>();

                    bool forceAdd = false;
                    if (i == 0)
                    {
                        forceAdd = true;
                    }
                    LogEvents_Check_add(_LogEvents_table, _LogFile_In_table[i], prevLogRec, forceAdd);
                }
                ;
                //for the storage of the last record
                LogEvents_Check_add(_LogEvents_table, _LogFile_In_table[_LogFile_In_table.Count() - 1], prevLogRec, true);
            }
            ;
            Console.WriteLine("End of Log Events");

            //now load LogEvents to the Display Log Events
            Disp_LogEvents_add(_Disp_LogEvents_table, LogEvents_table);
            Console.WriteLine("all display log events are created");


            //sort by machine
            for (int machNum = 0; machNum < NumMachines; machNum++)
            {
                //reset running sum
                TimeSpan totOnSpan   = new TimeSpan(0, 0, 0, 0);
                TimeSpan totOffSpan  = new TimeSpan(0, 0, 0, 0);
                TimeSpan totTimeSpan = new TimeSpan(0, 0, 0, 0);

                //load the first data
                Disp_LogMachEvents_rec newRec = new Disp_LogMachEvents_rec();  //new record
                string machNumStr             = "M" + RightStr(("000" + (machNum + 1).ToString().Trim()), 2);
                newRec.timeStartStr = ConvLogTimeToStr(_LogFile_In_table[0].timeInStr);

                bool oldStat = _LogFile_In_table[0].machStat[machNum];
                if (oldStat)
                {
                    newRec.machNum = machNumStr + " on";
                }
                else
                {
                    newRec.machNum = machNumStr + " off";
                }

                for (int i = 1; i < _LogFile_In_table.Count() - 1; i++)
                {
                    if (_LogFile_In_table[i].machStat[machNum] != oldStat)
                    {
                        //status has changed
                        newRec.timeStopStr = ConvLogTimeToStr(_LogFile_In_table[i].timeInStr);
                        newRec.timeDiffStr = CalcTimeDiffStr(newRec.timeStartStr, newRec.timeStopStr);
                        if (newRec.machNum.Contains("on"))
                        {
                            newRec.timeOnStr  = newRec.timeDiffStr;
                            newRec.timeOffStr = "";
                            totOnSpan         = AddToTime(totOnSpan, newRec.timeOnStr);
                            totTimeSpan       = AddToTime(totTimeSpan, newRec.timeOnStr);
                        }
                        else
                        {
                            newRec.timeOnStr  = "";
                            newRec.timeOffStr = newRec.timeDiffStr;
                            totOffSpan        = AddToTime(totOffSpan, newRec.timeOffStr);
                            totTimeSpan       = AddToTime(totTimeSpan, newRec.timeOffStr);
                        };
                        Disp_LogMachEvents_table.Add(newRec);
                        oldStat = _LogFile_In_table[i].machStat[machNum];

                        //now prepare for the next record
                        newRec = new Disp_LogMachEvents_rec();
                        newRec.timeStartStr = ConvLogTimeToStr(_LogFile_In_table[i].timeInStr);
                        if (oldStat)
                        {
                            newRec.machNum = machNumStr + " on";
                        }
                        else
                        {
                            newRec.machNum = machNumStr + " off";
                        }
                    }
                    ;
                }
                ;
                //loop ended so close out the record
                newRec.timeStopStr = ConvLogTimeToStr(_LogFile_In_table[_LogFile_In_table.Count() - 1].timeInStr);
                newRec.timeDiffStr = CalcTimeDiffStr(newRec.timeStartStr, newRec.timeStopStr);
                if (newRec.machNum.Contains("on"))
                {
                    newRec.timeOnStr  = newRec.timeDiffStr;
                    newRec.timeOffStr = "";
                    totOnSpan         = AddToTime(totOnSpan, newRec.timeOnStr);
                    totTimeSpan       = AddToTime(totTimeSpan, newRec.timeOnStr);
                }
                else
                {
                    newRec.timeOnStr  = "";
                    newRec.timeOffStr = newRec.timeDiffStr;
                    totOffSpan        = AddToTime(totOffSpan, newRec.timeOffStr);
                    totTimeSpan       = AddToTime(totTimeSpan, newRec.timeOffStr);
                };
                Disp_LogMachEvents_table.Add(newRec);

                newRec              = new Disp_LogMachEvents_rec();
                newRec.machNum      = "------------";
                newRec.timeStartStr = "";
                newRec.timeStopStr  = "";
                newRec.timeDiffStr  = "";
                newRec.timeOnStr    = "----------";
                newRec.timeOffStr   = "----------";
                Disp_LogMachEvents_table.Add(newRec);

                newRec              = new Disp_LogMachEvents_rec();
                newRec.machNum      = "total times";
                newRec.timeStartStr = "";
                newRec.timeStopStr  = "";
                //newRec.timeDiffStr = "";
                if (totTimeSpan.TotalHours == 0)
                {
                    newRec.timeDiffStr = "--";
                }
                else
                {
                    newRec.timeDiffStr = totTimeSpan.TotalHours.ToString("####.##") + " total";
                }
                if (totOnSpan.TotalHours == 0)
                {
                    newRec.timeOnStr = "--";
                }
                else
                {
                    newRec.timeOnStr = totOnSpan.TotalHours.ToString("####.##") + " hrs";
                }
                if (totOffSpan.TotalHours == 0)
                {
                    newRec.timeOffStr = "--";
                }
                else
                {
                    newRec.timeOffStr = totOffSpan.TotalHours.ToString("####.##") + " hrs";
                }

                /*
                 * newRec.timeOnStr = (totOnSpan.Days*24+totOnSpan.Hours).ToString().Trim() + ":" +
                 *  RightStr("000" + totOnSpan.Minutes.ToString().Trim(),2);
                 * newRec.timeOffStr = (totOffSpan.Days * 24 + totOffSpan.Hours).ToString().Trim() + ":" +
                 *  RightStr("000" + totOffSpan.Minutes.ToString().Trim(), 2);
                 */
                Disp_LogMachEvents_table.Add(newRec);

                newRec              = new Disp_LogMachEvents_rec();
                newRec.machNum      = "percentages";
                newRec.timeStartStr = "";
                newRec.timeStopStr  = "";
                newRec.timeDiffStr  = "";
                double OnPercent = (totOnSpan.TotalHours / totTimeSpan.TotalHours) * 100.00;
                if (OnPercent == 0)
                {
                    newRec.timeOnStr = "";
                }
                else
                {
                    newRec.timeOnStr = OnPercent.ToString("###.##") + "%";
                }

                double OffPercent = (totOffSpan.TotalHours / totTimeSpan.TotalHours) * 100.00;
                if (OffPercent == 0)
                {
                    newRec.timeOffStr = "";
                }
                else
                {
                    newRec.timeOffStr = OffPercent.ToString("###.##") + "%";
                }
                Disp_LogMachEvents_table.Add(newRec);

                newRec              = new Disp_LogMachEvents_rec();
                newRec.machNum      = "------------";
                newRec.timeStartStr = "";
                newRec.timeStopStr  = "";
                newRec.timeDiffStr  = "";
                newRec.timeOnStr    = "----------";
                newRec.timeOffStr   = "----------";
                Disp_LogMachEvents_table.Add(newRec);

                newRec              = new Disp_LogMachEvents_rec();
                newRec.machNum      = "";
                newRec.timeStartStr = "";
                newRec.timeStopStr  = "";
                newRec.timeDiffStr  = "";
                newRec.timeOnStr    = "";
                newRec.timeOffStr   = "";
                Disp_LogMachEvents_table.Add(newRec);
            }
            ;
        }
Beispiel #4
0
        public void LogEvents_Check_add(
            List <LogEvents_rec> _LogEvents_table,
            LogFile_In_rec _RecToStore,
            LogFile_In_rec _PrevRec,
            bool _ForceAdd
            )
        {
            //check if there is a change, if so add an event to the LogEvents table
            LogEvents_rec newRec = new LogEvents_rec();

            newRec.timeStartStr = ConvLogTimeToStr(_PrevRec.timeInStr);
            newRec.timeStopStr  = ConvLogTimeToStr(_RecToStore.timeInStr);
            newRec.timeDiffStr  = CalcTimeDiffStr(newRec.timeStartStr, newRec.timeStopStr);

            newRec.machStat          = new List <bool>();
            newRec.machStatStr       = new List <string>();
            newRec.machStatChanged   = new List <bool>();
            newRec.machStatChangeStr = new List <string>();
            bool isStatChanged = false;

            for (int i = 0; i < NumMachines; i++)
            {
                newRec.machStat.Add(_RecToStore.machStat[i]);
                if (_RecToStore.machStat[i])
                {
                    newRec.machStatStr.Add("on");
                }
                else
                {
                    newRec.machStatStr.Add("off");
                }

                if (_PrevRec.machStat[i] != _RecToStore.machStat[i])
                {
                    //there is a difference
                    isStatChanged      = true;
                    newRec.machStat[i] = _RecToStore.machStat[i];
                    newRec.machStatChanged.Add(true);
                    if (_RecToStore.machStat[i])
                    {
                        newRec.machStatChangeStr.Add("on");
                    }
                    else
                    {
                        newRec.machStatChangeStr.Add("off");
                    }
                }
                else
                {
                    //no change on this machine, but store in case there is another change
                    newRec.machStat[i] = _RecToStore.machStat[i];
                    newRec.machStatChanged.Add(false);
                    newRec.machStatChangeStr.Add(" ");  //nothing changed so just store blank string
                };
            }
            //after going thru all the machines, if something changed save the event
            if (isStatChanged || _ForceAdd)
            {
                _LogEvents_table.Add(newRec);
                //if record changed, reset the Prev Record
                _PrevRec.stringIn  = _RecToStore.stringIn;
                _PrevRec.timeInStr = _RecToStore.timeInStr;
                for (int j = 0; j < NumMachines; j++)
                {
                    _PrevRec.machStat[j] = _RecToStore.machStat[j];
                }
                ;
            }
            ;
        }