Exemplo n.º 1
0
        public Analysis Load(string dataSource)
        {
            string[] lines = System.IO.File.ReadAllLines(dataSource);

            if (IsOldVersion(lines))
            {
                throw new Exception("Please migrate the analysis file " + dataSource + " to version " + TwAssembly.Version() + " or later.");
            }

            double twConversionFactor = GetTwConversionFactor(lines);

            Attributes = LoadAttributes(lines);

            LogMeter log = LoadLog(lines);

            FixtureProfiles fixtureProfiles = LoadFixtureProfiles(lines);

            Events events = LoadEvents(lines);

            LoadFlows(lines, events);

            events.UpdateVolume();

            var analysis = new AnalysisDatabase(dataSource, events, log, fixtureProfiles);

            analysis.Events.ConversionFactor = twConversionFactor;
            analysis.Events.UpdateChannel();
            analysis.Events.UpdateSuperPeak();
            analysis.Events.UpdateLinkedList();
            analysis.Events.UpdateOriginalVolume();

            return(analysis);
        }
Exemplo n.º 2
0
        public override Log Load(string dataSource)
        {
            try {
                var log = new LogMeter(dataSource);

                string[] lines = System.IO.File.ReadAllLines(dataSource);

                log.FileName = dataSource;

                log.Customer = ReadCustomer(lines);
                log.Meter    = ReadMeter(lines);
                log.Flows    = ReadFlows(lines, TimeSpan.FromSeconds(log.Meter.StorageInterval.GetValueOrDefault()));

                if (log.Flows.Count > 0)
                {
                    log.StartTime = log.Flows[0].StartTime;
                    log.EndTime   = log.Flows[log.Flows.Count - 1].EndTime;
                }

                log.Update();
                return(log);
            } catch (System.Data.OleDb.OleDbException ex) {
                if (ex.Message.Contains("Could not find file"))
                {
                    throw new Exception("Could not find file");
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 3
0
 void WriteLogData(System.Text.StringBuilder text, LogMeter log)
 {
     WriteLogDates(text, log);
     WriteLogFileName(text, log);
     WriteCustomer(text, log.Customer);
     WriteMeter(text, log.Meter);
 }
Exemplo n.º 4
0
        LogMeter LoadLog(string[] lines)
        {
            bool logFound = false;

            foreach (string line in lines)
            {
                if (line.Contains("@LOG"))
                {
                    logFound = true;
                    break;
                }
            }

            LogMeter log = null;

            if (logFound)
            {
                log = new LogMeter();

                ReadLogDates(lines, log);
                ReadLogFileName(lines, log);

                log.Customer = ReadCustomer(lines);
                log.Meter    = ReadMeter(lines);
            }

            return(log);
        }
Exemplo n.º 5
0
        void WriteHeader(StringBuilder text, LogMeter log)
        {
            AppendKeyValuePair(text, "Format", "TraceWizardLog");
            AppendKeyValuePair(text, "Version", TwAssembly.Version().ToString());

            WriteCustomerInfo(text, log.Customer);
            WriteMeterInfo(text, log.Meter);
        }
Exemplo n.º 6
0
        void AddFlow(List <Flow> flows, OleDbDataReader reader, TimeSpan duration, LogMeter log)
        {
            DateTime  startTime = reader.GetDateTime(0);
            TimeFrame timeFrame = new TimeFrame(startTime, duration);
            double    rate      = reader.GetDouble(1);
            int       rawData   = reader.GetInt32(2);
            var       flow      = BuildFlow(timeFrame, rate, rawData, log);

            flows.Add(flow);
        }
Exemplo n.º 7
0
        public override Log Load(string dataSource)
        {
            //dataSource = ConvertFromAccess97(dataSource);

            var log = new LogMeter(dataSource);

            try {
                using (OleDbConnection connection = new OleDbConnection(DataServices.BuildJetConnectionString(dataSource, true))) {
                    connection.Open();
                    using (OleDbCommand command = new OleDbCommand()) {
                        command.Connection = connection;

                        log.FileName = dataSource;
                        log.Customer = AddCustomer(command);
                        log.Meter    = AddMeter(command);
                        log.Flows    = AddFlows(command, TimeSpan.FromSeconds(log.Meter.StorageInterval.GetValueOrDefault()), log);

                        if (log.Flows.Count > 0)
                        {
                            log.StartTime = log.Flows[0].StartTime;
                            log.EndTime   = log.Flows[log.Flows.Count - 1].EndTime;
                        }
                    }

                    log.Update();
                    return(log);
                }
            } catch (System.Data.OleDb.OleDbException ex) {
                if (ex.Message.Contains("Could not find file"))
                {
                    throw new Exception("Could not find file");
                }
                else if (ex.Message.Contains("Unrecognized database format"))
                {
                    throw new Exception("Unrecognized logger format");
                }
                else if (ex.Message.Contains("Cannot open a database created with a previous version of your application"))
                {
                    throw new Exception("The Microsoft Access 2007 Runtime is not properly installed on this system. Historically, this error has occured when Access 2010 or later has been run on this system.\r\n\r\nPlease review the " + TwAssembly.Title() + " System Requirements and reinstall/repair the Access 2007 Runtime.\r\n\r\n The original error message was: " + ex.Message);
                }
                else
                {
                    throw;
                }
            } catch (InvalidOperationException ex) {
                if (ex.Message.Contains("provider is not registered"))
                {
                    throw new Exception("The Microsoft Access 2007 Runtime is not installed on this system.\r\n\r\nPlease review the " + TwAssembly.Title() + " System Requirements and install the Access 2007 Runtime.\r\n\r\n(" + ex.Message + ")");
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 8
0
        public void Save(string dataSource, LogMeter log)
        {
            if (System.IO.File.Exists(dataSource))
            {
                System.IO.File.Delete(dataSource);
            }
            StringBuilder text = new System.Text.StringBuilder();

            WriteHeader(text, log);
            WriteData(text, log.Flows);
            System.IO.File.WriteAllText(dataSource, text.ToString());
        }
Exemplo n.º 9
0
        void WriteLog(System.Text.StringBuilder text, Log log)
        {
            LogMeter meterMasterLog = log as LogMeter;

            if (meterMasterLog != null)
            {
                WriteLine(text);
                WriteLogHeader(text);
                WriteLogData(text, meterMasterLog);
                WriteLine(text);
            }
        }
Exemplo n.º 10
0
        List <Flow> AddFlows(OleDbCommand command, TimeSpan duration, LogMeter log)
        {
            command.CommandText = BuildFlowsCommandText();
            List <Flow> flows = new List <Flow>();

            using (OleDbDataReader reader = command.ExecuteReader()) {
                while (reader.Read())
                {
                    AddFlow(flows, reader, duration, log);
                }
            }
            return(flows);
        }
Exemplo n.º 11
0
        void ReadLogFileName(string[] lines, LogMeter log)
        {
            foreach (string line in lines)
            {
                if (line.StartsWith("@DATA"))
                {
                    break;
                }

                if (CommentStartsWith(line, LogMeter.FileNameLabel))
                {
                    log.FileName = ReadStringValue(line);
                }
            }
        }
Exemplo n.º 12
0
        void ReadLogDates(string[] lines, LogMeter log)
        {
            foreach (string line in lines)
            {
                if (line.StartsWith("@DATA"))
                {
                    break;
                }

                if (CommentStartsWith(line, LogMeter.StartTimeLabel))
                {
                    log.StartTime = ReadDateTimeValue(line);
                }
                if (CommentStartsWith(line, LogMeter.EndTimeLabel))
                {
                    log.EndTime = ReadDateTimeValue(line);
                }
            }
        }
Exemplo n.º 13
0
        public void Initialize()
        {
            GeneralProperties.Analysis = Analysis;
            GeneralProperties.Initialize();

            HourlyTotalsDetail.Analysis = Analysis;
            HourlyTotalsDetail.Initialize();

            DailyTotalsDetail.Analysis = Analysis;
            DailyTotalsDetail.Initialize();

            LogMeter log = Analysis.Log as LogMeter;

            if (log != null)
            {
                LogPropertiesDetail.Log = log;
                LogPropertiesDetail.Initialize();
            }
        }
Exemplo n.º 14
0
        public override Log Load(string dataSource)
        {
            try {
                var log = new LogMeter(dataSource);
                log.Customer = new LogMeterCustomer();
                log.Meter    = new LogMeterMeter();

                string[] lines = System.IO.File.ReadAllLines(dataSource);

                log.FileName = dataSource;

                dateTimeFormat     = GetDateTimeFormat(dataSource, dateTimeFormat);
                seconds            = GetInterval(lines);
                nutationRate       = GetNutationRate(dataSource, nutationRate);
                log.Meter.Nutation = nutationRate;
                multiplier         = (60.0 / (double)seconds) * nutationRate;
                log.Customer.ID    = GetSiteId(lines);

                log.Flows = ReadFlows(lines, TimeSpan.FromSeconds(seconds));

                if (log.Flows.Count > 0)
                {
                    log.StartTime = log.Flows[0].StartTime;
                    log.EndTime   = log.Flows[log.Flows.Count - 1].EndTime;
                }

                log.Update();
                return(log);
            } catch (System.Data.OleDb.OleDbException ex) {
                if (ex.Message.Contains("Could not find file"))
                {
                    throw new Exception("Could not find file");
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 15
0
        public void Initialize()
        {
            log = Analysis.Log as LogMeter;
            if (log == null)
            {
                return;
            }
            if (log.Meter.MeterMasterVolume.HasValue)
            {
                LabelMeterMasterVolume.Text    = log.Meter.MeterMasterVolume.Value.ToString("0.0");
                LabelMeterMasterVolume.ToolTip = "Meter Master Volume";
            }

            bool volumeToleranceExceeded = Analysis.VolumeToleranceExceeded(log.Meter.MeterMasterVolume, 0.05);

            if (volumeToleranceExceeded)
            {
                LabelMeterMasterVolume.Background = new SolidColorBrush(Colors.Red);
                LabelMeterMasterVolume.ToolTip    = "Warning: Trace Wizard Volume differs significantly from Meter Master Volume";
            }

            if (log.Meter.RegisterVolume.HasValue)
            {
                LabelRegisterVolume.Text    = log.Meter.RegisterVolume.Value.ToString("0.0");
                LabelRegisterVolume.ToolTip = "Register Volume";
            }
            if (log.Meter.ConversionFactor.HasValue)
            {
                LabelConversionFactor.Text    = log.Meter.ConversionFactor.Value.ToString("0.00");
                LabelConversionFactor.ToolTip = "Conversion Factor";
            }
            Properties.Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Default_PropertyChanged);
            Visibility = SetVisibility();

            ButtonLog.MouseEnter += new MouseEventHandler(buttonLog_MouseEnter);
            ButtonLog.Click      += new RoutedEventHandler(buttonLog_Click);
        }
Exemplo n.º 16
0
        public void Initialize()
        {
            ClassifierMachineLearning = GetClassifierMachineLearning();
            var classifierFixtureList = new FixtureListClassifier();

            classifierFixtureList.FixtureProfiles = Analysis.FixtureProfiles;

            ClassifierComposite = new CompositeClassifier();
            ClassifierComposite.ClassifierMachineLearning = ClassifierMachineLearning;
            ClassifierComposite.ClassifierFixtureList     = classifierFixtureList;

            Analysis.UndoManager.RenderEvent   = StyledEventsViewer.EventsViewer.LinedEventsCanvas.RenderEvent;
            Analysis.UndoManager.RemovePolygon = StyledEventsViewer.EventsViewer.LinedEventsCanvas.Remove;

            StyledEventsViewer.EventsViewer.LinedEventsCanvas.PropertyChanged += new PropertyChangedEventHandler(EventsCanvas_PropertyChanged);
            GraphToolBar.PropertyChanged += new PropertyChangedEventHandler(GraphToolBar_PropertyChanged);
            CommandPanel.PropertyChanged += new PropertyChangedEventHandler(CommandPanel_PropertyChanged);

            GraphToolBar.Analysis     = Analysis;
            GraphToolBar.FeatureLevel = FeatureLevel;
            GraphToolBar.UndoManager  = Analysis.UndoManager;
            GraphToolBar.ClassifierMachineLearning = ClassifierMachineLearning;
            //GraphToolBar.ClassifierFixtureList = classifierComposite;
            GraphToolBar.Initialize();

            CommandPanel.AnalysisPanel = this;
            CommandPanel.Initialize();

            FixtureProfilesEditor.Analysis = this.Analysis;
            FixtureProfilesEditor.Initialize();

            Binding binding;

            if (Properties.Settings.Default.ShowEventPanelsOnLeft)
            {
                dockEventPanelsHorizontal.Visibility = Visibility.Collapsed;

                SelectedEventPanelVertical.Analysis = Analysis;
                Analysis.Events.PropertyChanged    += new PropertyChangedEventHandler(SelectedEventPanelVertical.Events_PropertyChanged);
                SelectedEventPanelVertical.Initialize();
                binding        = new Binding("Visibility");
                binding.Source = SelectedEventPanelVertical;
                BindingOperations.SetBinding(SeparatorSelectedEventPanelVertical, VisibilityProperty, binding);

                CurrentEventPanelVertical.Analysis = Analysis;
                StyledEventsViewer.EventsViewer.LinedEventsCanvas.PropertyChanged += new PropertyChangedEventHandler(CurrentEventPanelVertical.EventsCanvas_PropertyChanged);
                CurrentEventPanelVertical.ShowSelectedEvent = false;
                CurrentEventPanelVertical.Initialize();
            }
            else
            {
                dockEventPanelsVertical.Visibility = Visibility.Collapsed;

                SelectedEventPanel.Analysis      = Analysis;
                Analysis.Events.PropertyChanged += new PropertyChangedEventHandler(SelectedEventPanel.Events_PropertyChanged);
                SelectedEventPanel.Initialize();
                binding        = new Binding("Visibility");
                binding.Source = SelectedEventPanel;
                BindingOperations.SetBinding(SeparatorSelectedEventPanel, VisibilityProperty, binding);

                CurrentEventPanel.Analysis = Analysis;
                StyledEventsViewer.EventsViewer.LinedEventsCanvas.PropertyChanged += new PropertyChangedEventHandler(CurrentEventPanel.EventsCanvas_PropertyChanged);
                CurrentEventPanel.ShowSelectedEvent = false;
                CurrentEventPanel.Initialize();
                binding        = new Binding("Visibility");
                binding.Source = CurrentEventPanel;
                BindingOperations.SetBinding(SeparatorCurrentEventPanel, VisibilityProperty, binding);
            }

            LogMeter log = Analysis.Log as LogMeter;

            if (log == null)
            {
                LogPropertiesPanel.Visibility = Visibility.Collapsed;
            }
            else
            {
                LogPropertiesPanel.Analysis = Analysis;
                LogPropertiesPanel.Initialize();
            }

            binding        = new Binding("Visibility");
            binding.Source = LogPropertiesPanel;
            BindingOperations.SetBinding(SeparatorLogPanel, VisibilityProperty, binding);

            PieChartsPanel.Analysis = Analysis;
            PieChartsPanel.Initialize();

            binding        = new Binding("Visibility");
            binding.Source = PieChartsPanel;
            BindingOperations.SetBinding(SeparatorPieChartsPanel, VisibilityProperty, binding);

            ReportsPanel.Analysis = Analysis;
            ReportsPanel.Initialize();

            binding        = new Binding("Visibility");
            binding.Source = ReportsPanel;
            BindingOperations.SetBinding(SeparatorReportsPanel, VisibilityProperty, binding);

            FixturesPanel.Analysis = Analysis;
            FixturesPanel.Initialize();

            StyledEventsViewer.EventsViewer.LinedEventsCanvas.ClassifierDisaggregation = ClassifierComposite;
            StyledEventsViewer.Events          = Analysis.Events;
            StyledEventsViewer.ViewportSeconds = ViewportSeconds;
            StyledEventsViewer.ViewportVolume  = ViewportVolume;
            StyledEventsViewer.Initialize();
        }
Exemplo n.º 17
0
 public virtual Flow BuildFlow(TimeFrame timeFrame, double rate, int rawData, LogMeter log)
 {
     return(new MeterMasterJetFlow(timeFrame, rate, rawData));
 }