Exemplo n.º 1
0
 private void calculate(Chart_GUI chart_gui_)
 {
     range       = nice_num(timeslice.end - timeslice.start, false);
     tickSpacing = nice_num(range / (maxTicks - 1), true);
     niceMin     = Math.Floor(timeslice.start / tickSpacing) * tickSpacing;
     niceMax     = Math.Ceiling(timeslice.end / tickSpacing) * tickSpacing;
 }
Exemplo n.º 2
0
        public void set_parameters(Chart_GUI chart_gui_)
        {
            timeslice = chart_gui_.timeslice;
            maxTicks  = chart_gui_.chart_area_width / 5; // Max number of ticks is one tick every 5 distance

            calculate(chart_gui_);
        }
Exemplo n.º 3
0
 public NiceScale(Chart_GUI chart_gui_) // If there is a chart area to nice scale
 {
     if (chart_gui_.chart.ChartAreas.Count != 0)
     {
         set_parameters(chart_gui_);
     }
 }
Exemplo n.º 4
0
        public Loading_Bar_Parser(Chart_GUI chart_gui_, CheckedListBox checked_list_box_)
        {
            InitializeComponent();

            chart_gui        = chart_gui_;
            checked_list_box = checked_list_box_;

            label_FileName.Text = Path.GetFileName(chart_gui.logfile.path);
        }
Exemplo n.º 5
0
        private void openToolStripMenuItem_database_Click(object sender, EventArgs e)
        {
            // Open file dialog
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter           = "dbc files (*.dbc)|*.dbc";
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    // Check if duplicate
                    if (chart_gui.database_set.databases.Exists(x => !Convert.ToBoolean(string.Compare(x.path, openFileDialog.FileName))))
                    {
                        MessageBox.Show("Database already included!");
                    }
                    else
                    {
                        // Create new database and add to database_set
                        Database new_database = new Database();
                        new_database.path = openFileDialog.FileName;
                        new_database.parse(new_database.path);

                        chart_gui.database_set.databases.Add(new_database);

                        // Add new database to treeview
                        TreeNode new_database_node = new TreeNode(Path.GetFileName(new_database.path));
                        treeView_tree.Nodes[1].Nodes.Add(new_database_node);
                        treeView_tree.Nodes[1].Expand();

                        // If logfile already exists, reparse logfile
                        if (chart_gui.logfile.path != null)
                        {
                            // Parse logfile
                            //chart_gui.logfile.parse(chart_gui.database_set);
                            // Experimental loading bar parser
                            Loading_Bar_Parser parser = new Loading_Bar_Parser(chart_gui, checkedListBox_signals);
                            parser.ShowDialog();
                            chart_gui = parser.chart_gui;

                            // Update logfile in chart
                            chart_gui.update_logfile(chart_gui.checked_list_box);

                            // Set initial chart to show timeslice of entire logfile
                            chart_gui.set_initial_timeslice_data();
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void CAN_Viewer_Main_Load(object sender, EventArgs e)
        {
            // Initialize status strip with "none" text
            statusStrip_status.GripStyle = ToolStripGripStyle.Hidden;
            statusStrip_status.Items.AddRange(new ToolStripItem[] { status_text });

            statusStrip_status.LayoutStyle      = ToolStripLayoutStyle.HorizontalStackWithOverflow;
            statusStrip_status.ShowItemToolTips = true;
            statusStrip_status.SizingGrip       = false;
            statusStrip_status.Stretch          = false;
            statusStrip_status.TabIndex         = 0;

            status_text.Size = new System.Drawing.Size(109, 17);
            status_text.Text = "[no logfile selected]";

            // Initialize treeview with logfile and database root nodes
            TreeNode root_logfile = new TreeNode("CAN Logfiles");

            treeView_tree.Nodes.Add(root_logfile);

            TreeNode root_database = new TreeNode("CAN Databases");

            treeView_tree.Nodes.Add(root_database);

            // Set Chart_GUI chart instance to default chart in designer
            chart_gui = new Chart_GUI(chart, checkedListBox_signals);

            // Initialize mouse wheel event in chart_gui
            chart_gui.initialize_mouse_wheel_event(this);

            // Initialize form resize event in chart_gui
            chart_gui.initialize_form_resize_event(this);

            // Set checked list box
            chart_gui.checked_list_box = checkedListBox_signals;

            // Allows components to be accessed across threads
            Control.CheckForIllegalCrossThreadCalls = false;
        }
Exemplo n.º 7
0
        private void openToolStripMenuItem_logfile_Click(object sender, EventArgs e)
        {
            // Open file dialog
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter           = "txt files (*.txt)|*.txt";
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    // Check if same as currently existing
                    if (!Convert.ToBoolean(string.Compare(chart_gui.logfile.path, openFileDialog.FileName)))
                    {
                        MessageBox.Show("Same logfile already loaded!");
                    }
                    else
                    {
                        // Set logfile path, will be parsed in Logfile_Parser
                        chart_gui.logfile.path = openFileDialog.FileName;

                        // Parse logfile
                        //chart_gui.logfile.parse(chart_gui.database_set);
                        // Experimental loading bar parser, if cancels, overwrites log file with new instantiation
                        Loading_Bar_Parser parser = new Loading_Bar_Parser(chart_gui, checkedListBox_signals);
                        parser.ShowDialog();
                        chart_gui = parser.chart_gui;

                        // Check if cancelled
                        if (chart_gui.logfile.path == null)
                        {
                            return;
                        }

                        // Update logfile in chart
                        //chart_gui.update_logfile(chart_gui.checked_list_box);

                        // Update status bar text
                        status_text.Text = Path.GetFileName(chart_gui.logfile.path);

                        // Add to treeview
                        TreeNode new_logfile_node = new TreeNode(Path.GetFileName(chart_gui.logfile.path));
                        treeView_tree.Nodes[0].Nodes.Add(new_logfile_node);
                        treeView_tree.Nodes[0].Expand();

                        // Populate checkedListBox with all logfile signals
                        chart_gui.logfile.update_CheckedListBox(checkedListBox_signals);

                        //// Update now updated logfile in chart_gui
                        //if (chart_gui.update_logfile(logfile, database_set, checkedListBox_signals) == 0)
                        //    throw new ArgumentException("chart_gui cannot be updated with null logfile argument");

                        //Logfile_Parser parser = new Logfile_Parser(chart_gui, database_set, checkedListBox_signals);
                        //parser.Show();

                        // Set initial chart to show timeslice of entire logfile
                        chart_gui.set_initial_timeslice_data();
                    }
                }
            }

            /*
             * // Set initial gui window to entire logfile timeslice, with some padding
             * if (logfile.num_points != 0)
             * {
             *  gui.time_start = logfile.point_list[0].timestamp - 0.1 * (logfile.point_list[logfile.num_points - 1].timestamp - logfile.point_list[0].timestamp);
             *  gui.time_end = logfile.point_list[logfile.num_points - 1].timestamp + 0.1 * (logfile.point_list[logfile.num_points - 1].timestamp - logfile.point_list[0].timestamp);
             * }
             * else
             *  MessageBox.Show("Logfile empty");
             */
        }