Ejemplo n.º 1
0
            public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
            {
                if (destType == typeof(string) && value is SymbolHelper)
                {
                    // Cast the value to an Employee type
                    SymbolHelper pp = (SymbolHelper)value;

                    return(pp.Varname + ", " + pp.Start_address + ", " + pp.Length);
                }
                return(base.ConvertTo(context, culture, value, destType));
            }
Ejemplo n.º 2
0
 public void AddSymbolToWatchlist(string symbolname, Int32 sramaddress, Int32 length, bool systemSymbol)
 {
     _stallReading = true;
     if (symbolname != "")
     {
         SymbolHelper sh = new SymbolHelper();
         sh.Varname = symbolname;
         sh.Start_address = sramaddress;
         sh.Length = length;
         sh.IsSystemSymbol = systemSymbol;
         if (!CollectionContains(symbolname)) // maybe use systemSymbol as well <GS-11042011>
         {
             m_SymbolsToMonitor.Add(sh);
         }
     }
     _stallReading = false;
 }
Ejemplo n.º 3
0
        private void LoadUserDefinedRealtimeSymbols()
        {
            string savePath = Path.Combine(Application.LocalUserAppDataPath, "rtsymbols.txt");
            if (File.Exists(savePath))
            {
                m_RealtimeUserSymbols = new Trionic5Tools.SymbolCollection(); // first empty
                char[] sep = new char[1];
                sep.SetValue(';', 0);
                using (StreamReader sr = new StreamReader(savePath))
                {
                    string line = string.Empty;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] values = line.Split(sep);

                        foreach (Trionic5Tools.SymbolHelper sh in m_trionicFileInformation.SymbolCollection)
                        {
                            if (sh.Varname == values.GetValue(0).ToString())
                            {
                                Trionic5Tools.SymbolHelper shnew = new Trionic5Tools.SymbolHelper();
                                shnew.Varname = sh.Varname;
                                shnew.Flash_start_address = sh.Flash_start_address;
                                shnew.Length = sh.Length;
                                shnew.Start_address = sh.Start_address;
                                shnew.Color = sh.Color;
                                shnew.UserCorrectionFactor = ConvertToDouble(values.GetValue(1).ToString());
                                shnew.UserCorrectionOffset = ConvertToDouble(values.GetValue(2).ToString());
                                shnew.UseUserCorrection = true;
                                m_RealtimeUserSymbols.Add(shnew);
                            }
                        }
                    }
                }
                ctrlRealtime1.SetRealtimeSymbollist(m_RealtimeUserSymbols);
            }
        }
Ejemplo n.º 4
0
 public int IndexOf(SymbolHelper value)
 {
     return(List.IndexOf(value));
 }
Ejemplo n.º 5
0
        private void LoadUserDefinedRealtimeSymbols(string filename)
        {
            if (File.Exists(filename))
            {
                m_watchListCollection = new Trionic5Tools.SymbolCollection(); // first empty
                char[] sep = new char[1];
                sep.SetValue(';', 0);
                using (StreamReader sr = new StreamReader(filename))
                {
                    string line = string.Empty;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] values = line.Split(sep);

                        foreach (Trionic5Tools.SymbolHelper sh in m_RealtimeSymbolCollection)
                        {
                            if (sh.Varname == values.GetValue(0).ToString())
                            {
                                Trionic5Tools.SymbolHelper shnew = new Trionic5Tools.SymbolHelper();
                                shnew.Varname = sh.Varname;
                                shnew.Flash_start_address = sh.Flash_start_address;
                                shnew.Length = sh.Length;
                                shnew.Start_address = sh.Start_address;
                                shnew.Color = sh.Color;
                                shnew.UserCorrectionFactor = ConvertToDouble(values.GetValue(1).ToString());
                                shnew.UserCorrectionOffset = ConvertToDouble(values.GetValue(2).ToString());
                                shnew.UseUserCorrection = true;
                                m_watchListCollection.Add(shnew);
                            }
                        }
                    }
                }
                SetRealtimeSymbollist(m_watchListCollection);
            }
        }
Ejemplo n.º 6
0
        private bool TryToAddSymbolToCollection(string hexstring, SymbolCollection curSymbolCollection)
        {
            //1A 0C 00 05 41 4D 4F 53 5F 73 74 61 74 75 73 00
            //19 3A 00 04 49 6E 74 5F 61 64 72 65 73 73
            //19 74 00 04 44 61 5F 35
            //40 B6 00 01 42 75 69 6C 64 5F 75 70 5F 74 69 6D 65 5F 73 77 69 74 63 68 21 00
            bool retval = false;
            int address = 0x00000;
            int length = 0x00;
            bool symbol_invalid = false;
            int invalid_char_count = 0;
            string name = string.Empty;
            try
            {
                address = Convert.ToInt32(hexstring.Substring(0, 5).Replace(" ", ""), 16);
                length = Convert.ToInt32(hexstring.Substring(6, 5).Replace(" ", ""), 16);
                for (int i = 12; i < hexstring.Length; i += 3)
                {
                    int val = Convert.ToInt16(hexstring.Substring(i, 3).Replace(" ", ""), 16);
                    if (val < 10) invalid_char_count++;
                    if (invalid_char_count > 2) symbol_invalid = true;
                    name += Convert.ToChar(val);
                }

                if (symbol_invalid)
                {
                    //AddLogItem("Found invalid symbol: " + name + " at " + address.ToString("X4") + " len " + length.ToString("X4"));
                }
                else
                {
                    name = name.Replace("\0", "");
                    if (name.Length > 0)
                    {
                        SymbolHelper sh = new SymbolHelper();
                        sh.Varname = name;
                        sh.Start_address = address;
                        sh.Length = length;
                        curSymbolCollection.Add(sh);
                        /*if (name == "Tryck_mat!")
                        {
                            SymbolHelper sh2 = new SymbolHelper();
                            sh2.Varname = "Pressure map scaled for 3 bar mapsensor";
                            sh2.Start_address = address;
                            sh2.Length = length;
                            curSymbolCollection.Add(sh2);
                        }
                        if (name == "Tryck_mat_a!")
                        {
                            SymbolHelper sh2 = new SymbolHelper();
                            sh2.Varname = "Pressure map (AUT) scaled for 3 bar mapsensor";
                            sh2.Start_address = address;
                            sh2.Length = length;
                            curSymbolCollection.Add(sh2);
                        }*/

                        retval = true;
                    }
                    else
                    {
                        retval = false;
                    }
                }

            }
            catch (Exception E)
            {
            //                AddLogItem("Failed to convert symbol: " + E.Message);
                Console.WriteLine(E.Message);
            }
            return retval;
        }
Ejemplo n.º 7
0
 public int Add(SymbolHelper value)
 {
     return (List.Add(value));
 }
Ejemplo n.º 8
0
 public void Insert(int index, SymbolHelper value)
 {
     List.Insert(index, value);
 }
Ejemplo n.º 9
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            if (gridControl1.DataSource != null)
            {
                DataTable dt = (DataTable)gridControl1.DataSource;

                foreach (DataRow dr in dt.Rows)
                {
                    SaveColorToRegistry(dr["SYMBOLNAME"].ToString(), Color.FromArgb(Convert.ToInt32(dr["COLOR"])));
                }

                int[] selrows = gridView1.GetSelectedRows();
                foreach (int rowhandle in selrows)
                {
                    DataRowView dv = (DataRowView)gridView1.GetRow(rowhandle);
                    if (dv != null)
                    {
                        SymbolHelper sh = new SymbolHelper();
                        sh.Varname = dv.Row["SYMBOLNAME"].ToString();
                        sh.Color = Color.FromArgb(Convert.ToInt32(dv.Row["COLOR"]));
                        _sc.Add(sh);
                    }
                }

            }

            /*
            foreach (DevExpress.XtraEditors.Controls.CheckedListBoxItem item in checkedListBoxControl1.Items)
            {
                if (item.CheckState == CheckState.Checked)
                {
                    SymbolHelper sh = new SymbolHelper();
                    sh.Varname = item.Value.ToString();
                    _sc.Add(sh);
                }
            }*/
            this.Close();
        }
Ejemplo n.º 10
0
        private void SaveMyMaps(string filename)
        {
            if (gridControl1.DataSource != null)
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
                DataTable dt = (DataTable)gridControl1.DataSource;
                XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document
                XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
                doc.AppendChild(dec);// Create the root element
                XmlElement root = doc.CreateElement("categories");
                doc.AppendChild(root);

                SymbolCollection sc = new SymbolCollection();

                // first get all categories
                foreach (DataRow dr in dt.Rows)
                {
                    string category = dr["category"].ToString();
                    bool found = false;
                    foreach(SymbolHelper sh in sc)
                    {
                        if (sh.Varname == category) found = true;
                    }
                    if (!found)
                    {
                        SymbolHelper newsh = new SymbolHelper();
                        newsh.Varname = category;
                        sc.Add(newsh);
                    }
                }

                foreach (SymbolHelper sh in sc)
                {
                    XmlElement title = doc.CreateElement("category");
                    title.SetAttribute("title", sh.Varname);
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr["category"].ToString() == sh.Varname)
                        {
                            XmlElement map = doc.CreateElement("map");
                            map.SetAttribute("symbol", dr["symbol"].ToString());
                            map.SetAttribute("title", dr["title"].ToString());
                            title.AppendChild(map);
                        }
                    }
                    root.AppendChild(title);
                }
                /*
                                    foreach (DataRow dr in dt.Rows)
                                    {
                                        XmlElement title = doc.CreateElement("category");
                                        title.SetAttribute("title", dr["category"].ToString());
                                        XmlElement map = doc.CreateElement("map");
                                        map.SetAttribute("symbol", dr["symbol"].ToString());
                                        map.SetAttribute("title", dr["title"].ToString());
                                        title.AppendChild(map);
                                        root.AppendChild(title);
                                    }
                 * */
                doc.Save(filename);

            }
        }
Ejemplo n.º 11
0
 public bool Contains(SymbolHelper value)
 {
     // If value is not of type Int16, this will return false.
     return(List.Contains(value));
 }
Ejemplo n.º 12
0
 public void Remove(SymbolHelper value)
 {
     List.Remove(value);
 }
Ejemplo n.º 13
0
 public void Insert(int index, SymbolHelper value)
 {
     List.Insert(index, value);
 }
Ejemplo n.º 14
0
 public void AddSymbolToWatchlist(SymbolHelper shuser, bool systemSymbol)
 {
     _stallReading = true;
     if (shuser.Varname != "")
     {
         SymbolHelper sh = new SymbolHelper();
         sh.Varname = shuser.Varname;
         sh.Start_address = shuser.Start_address;
         sh.Length = shuser.Length;
         sh.UserCorrectionFactor = shuser.UserCorrectionFactor;
         sh.UserCorrectionOffset = shuser.UserCorrectionOffset;
         sh.UseUserCorrection = shuser.UseUserCorrection;
         sh.IsSystemSymbol = systemSymbol;
         if (!CollectionContains(shuser.Varname)) // maybe use systemSymbol as well <GS-11042011>
         {
             m_SymbolsToMonitor.Add(sh);
         }
     }
     _stallReading = false;
 }
Ejemplo n.º 15
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            // setup the export filters
            LogFilters filterhelper = new LogFilters();
            frmLogFilters frmfilters = new frmLogFilters();
            LogFilterCollection filters = filterhelper.GetFiltersFromRegistry();
            Console.WriteLine("filters: " + filters.Count);
            frmfilters.SetFilters(filters);
            if (gridControl1.DataSource != null)
            {
                DataTable dt = (DataTable)gridControl1.DataSource;

                int[] selrows = gridView1.GetSelectedRows();
                foreach (int rowhandle in selrows)
                {
                    DataRowView dv = (DataRowView)gridView1.GetRow(rowhandle);
                    if (dv != null)
                    {
                        SymbolHelper sh = new SymbolHelper();
                        sh.Varname = dv.Row["SYMBOLNAME"].ToString();
                        sh.Color = Color.FromArgb(Convert.ToInt32(dv.Row["COLOR"]));
                        _sc.Add(sh);
                    }
                }

            }
            frmfilters.SetSymbols(_sc);
            if (frmfilters.ShowDialog() == DialogResult.OK)
            {
                DialogResult = DialogResult.None;
                filterhelper.SaveFiltersToRegistry(frmfilters.GetFilters());
            }
        }
Ejemplo n.º 16
0
 public int IndexOf(SymbolHelper value)
 {
     return (List.IndexOf(value));
 }
Ejemplo n.º 17
0
        private void btnViewMatrixFromLog_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // let the user select x axis, y axis and z axis symbols from the logfile
            //
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Trionic 5 logfiles|*.t5l";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string[] alllines = File.ReadAllLines(ofd.FileName);
                avgTable = null;
                System.Windows.Forms.Application.DoEvents();
                DateTime startDate = DateTime.MaxValue;
                DateTime endDate = DateTime.MinValue;
                Trionic5Tools.SymbolCollection sc = new Trionic5Tools.SymbolCollection();
                try
                {
                    //using (StreamReader sr = new StreamReader(ofd.FileName))

                    {
                        //string line = string.Empty;
                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)
                        foreach(string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            bool sfound = false;
                                            foreach (Trionic5Tools.SymbolHelper sh in sc)
                                            {
                                                if (sh.Varname == varname)
                                                {
                                                    sfound = true;
                                                }
                                            }
                                            Trionic5Tools.SymbolHelper nsh = new Trionic5Tools.SymbolHelper();
                                            nsh.Varname = varname;
                                            if (!sfound) sc.Add(nsh);
                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    Console.WriteLine(pE.Message);
                                }
                            }
                        }
                    }
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                }
                frmMatrixSelection sel = new frmMatrixSelection();
                sel.SetSymbolList(sc);
                sel.SetXSelection(m_appSettings.LastXAxisFromMatrix);
                sel.SetYSelection(m_appSettings.LastYAxisFromMatrix);
                sel.SetZSelection(m_appSettings.LastZAxisFromMatrix);
                if (sel.ShowDialog() == DialogResult.OK)
                {
                    // get selected for x, y and z
                    int type = sel.GetViewType(); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values
                    string x = sel.GetXAxisSymbol();
                    string y = sel.GetYAxisSymbol();
                    string z = sel.GetZAxisSymbol();
                    m_appSettings.LastXAxisFromMatrix = x;
                    m_appSettings.LastYAxisFromMatrix = y;
                    m_appSettings.LastZAxisFromMatrix = z;
                    double xmin = Double.MaxValue;
                    double xmax = Double.MinValue;
                    double ymin = Double.MaxValue;
                    double ymax = Double.MinValue;
                    double zmin = Double.MaxValue;
                    double zmax = Double.MinValue;
                    //using (StreamReader sr = new StreamReader(ofd.FileName))
                    {
                        //string line = string.Empty;
                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)
                        foreach(string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            double value = ConvertToDouble((string)subvals.GetValue(1));

                                            if (value > 65535) value = 0;
                                            if (value < -65535) value = 0;
                                            if (varname == x)
                                            {
                                                // get max and min

                                                if (value > xmax) xmax = value;
                                                if (value < xmin) xmin = value;
                                            }
                                            else if (varname == y)
                                            {
                                                // get max and min
                                                if (value > ymax) ymax = value;
                                                if (value < ymin) ymin = value;
                                            }
                                            else if (varname == z)
                                            {
                                                // get max and min
                                                if (value > zmax) zmax = value;
                                                if (value < zmin) zmin = value;
                                            }

                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    Console.WriteLine(pE.Message);
                                }
                            }
                        }
                    }
                    // now we have it all
                    if (xmin == xmax || ymin == ymax)
                    {
                        frmInfoBox info = new frmInfoBox("No data to display ... x or y axis contains no differentiated values");
                        return;
                    }
                    frmMatrixResult result = new frmMatrixResult();
                    result.SetViewType(type); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values
                    // parse the file again and add the points
                    DataTable dtresult = new DataTable();
                    // xmin = -0.8
                    // xmin = 2.01
                    double[] x_values = new double[16];
                    double[] y_values = new double[16];

                    // fill x and y axis
                    for (int i = 0; i < 16; i++)
                    {

                        double xvalue = xmin;
                        if(i>0) xvalue = xmin + i * ((xmax - xmin) / (15));
                        //Console.WriteLine("Adding: " + xvalue.ToString());
                        dtresult.Columns.Add(xvalue.ToString(), Type.GetType("System.Double"));
                        x_values.SetValue(xvalue, i); //    test: andersom?
                    }
                    for (int i = 0; i < 16; i++)
                    {
                        //double yvalue = ymin + ((ymax - ymin) / i);
                        double yvalue = ymin;
                        if (i > 0) yvalue = ymin + i * ((ymax - ymin) / (15));
                        y_values.SetValue(yvalue, i); //    test: andersom?
                    }
                    for (int i = 0; i < 16; i++)
                    {
                        dtresult.Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                    }
                    // table filled
                    double _lastX = 0;
                    double _lastY = 0;
                    double _lastZ = 0;

                    //using (StreamReader sr = new StreamReader(ofd.FileName))
                    {
                        //string line = string.Empty;
                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)
                        foreach(string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            double value = ConvertToDouble((string)subvals.GetValue(1));
                                            if (varname == x)
                                            {
                                                _lastX = value;
                                            }
                                            else if (varname == y)
                                            {
                                                _lastY = value;
                                            }
                                            else if (varname == z)
                                            {
                                                _lastZ = value;
                                            }

                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    Console.WriteLine(pE.Message);
                                }
                                // add point to the datatable
                                AddPointToDataTable(dtresult, _lastX, _lastY, _lastZ, xmin, xmax, ymin, ymax, zmin, zmax, type);
                            }
                        }
                    }
                    result.MaxValue = zmax;
                    result.MinValue = zmin;
                    result.SetXAxis(x_values);
                    result.SetYAxis(y_values);
                    result.SetXAxisName(x);
                    result.SetYAxisName(y);
                    result.SetZAxisName(z);
                    if (m_appSettings.MapViewerType == MapviewerType.Fancy) result.UseNewMapViewer = true;
                    result.SetTable(dtresult);
                    string typedescr = " (Mean values)";
                    if (type == 1) typedescr = " (Minimum values)";
                    else if (type == 1) typedescr = " (Maximum values)";
                    result.Text = "Matrix [" + x + " : " + y + " : " + z + "]" + typedescr;
                    //result.ShowDialog();
                    byte[] m_map_content = new byte[16 * 16 * 2];
                    int idx = 0;
                    for (int i = 15; i >= 0; i--)
                    {
                        foreach (object o in dtresult.Rows[i].ItemArray)
                        {
                            double value = Convert.ToDouble(o);
                            // now convert to int * 100
                            Int32 ivalue = 0;
                            try
                            {
                                ivalue = Convert.ToInt32(value * 100);
                            }
                            catch (Exception E)
                            {
                                Console.WriteLine("Failed to convert to integer value: " + value.ToString());
                            }
                            byte b1 = 0;
                            byte b2 = 0;
                            try
                            {
                                b1 = Convert.ToByte(ivalue / 256);
                                b2 = Convert.ToByte(ivalue - (int)b1 * 256);
                            }
                            catch (Exception E)
                            {
                                Console.WriteLine("Failed to convert to byte value + " + ivalue.ToString());
                            }

                            m_map_content[idx++] = b1;
                            m_map_content[idx++] = b2;
                        }
                    }
                    //<GS-28102010> for test, start a mapviewer as well
                    result.ShowDialog();
                    //StartResultViewerForMatrix(x_values, y_values, x, y, z, dtresult, m_map_content);
                }
            }
        }
Ejemplo n.º 18
0
 public void Remove(SymbolHelper value)
 {
     List.Remove(value);
 }
Ejemplo n.º 19
0
        private void ConvertFileToDif(string filename, bool AutoExport)
        {
            System.Windows.Forms.Application.DoEvents();
            DateTime startDate = DateTime.MaxValue;
            DateTime endDate = DateTime.MinValue;
            try
            {
                Trionic5Tools.SymbolCollection sc = new Trionic5Tools.SymbolCollection();
                string[] alllines = File.ReadAllLines(filename);
                //using (StreamReader sr = new StreamReader(filename))
                {
                    //string line = string.Empty;
                    char[] sep = new char[1];
                    char[] sep2 = new char[1];
                    //int linecount = 0;
                    sep.SetValue('|', 0);
                    sep2.SetValue('=', 0);
                    //while ((line = sr.ReadLine()) != null)
                    foreach(string line in alllines)
                    {
                        string[] values = line.Split(sep);
                        if (values.Length > 0)
                        {
                            try
                            {
                                //dd/MM/yyyy HH:mm:ss
                                //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                string dtstring = (string)values.GetValue(0);
                                DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                if (dt > endDate) endDate = dt;
                                if (dt < startDate) startDate = dt;
                                for (int t = 1; t < values.Length; t++)
                                {
                                    string subvalue = (string)values.GetValue(t);
                                    string[] subvals = subvalue.Split(sep2);
                                    if (subvals.Length == 2)
                                    {
                                        string varname = (string)subvals.GetValue(0);
                                        bool sfound = false;
                                        foreach (Trionic5Tools.SymbolHelper sh in sc)
                                        {
                                            if (sh.Varname == varname)
                                            {
                                                sfound = true;
                                            }
                                        }
                                        Trionic5Tools.SymbolHelper nsh = new Trionic5Tools.SymbolHelper();
                                        nsh.Varname = varname;
                                        if (!sfound) sc.Add(nsh);
                                    }
                                }
                            }
                            catch (Exception pE)
                            {
                                Console.WriteLine(pE.Message);
                            }
                        }
                    }
                }

                if (AutoExport)
                {
                    foreach (Trionic5Tools.SymbolHelper sh in sc)
                    {
                        sh.Color = GetColorFromRegistry(sh.Varname);
                    }
                    DifGenerator difgen = new DifGenerator();

                    difgen.LowAFR = m_appSettings.WidebandLowAFR / 1000;
                    difgen.HighAFR = m_appSettings.WidebandHighAFR / 1000;
                    difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage / 1000;
                    difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage / 1000;
                    difgen.WidebandSymbol = m_appSettings.WidebandLambdaSymbol;
                    difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;

                    difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                    System.Windows.Forms.Application.DoEvents();
                    try
                    {
                        difgen.ConvertFileToDif(filename, sc, startDate, endDate, true, true);
                    }
                    catch (Exception expE1)
                    {
                        Console.WriteLine(expE1.Message);
                    }
                }
                else
                {

                    // show selection screen
                    frmPlotSelection plotsel = new frmPlotSelection();
                    foreach (Trionic5Tools.SymbolHelper sh in sc)
                    {
                        if (sh.Varname != "Pgm_status")
                        {
                            plotsel.AddItemToList(sh.Varname);
                        }
                    }
                    plotsel.Startdate = startDate;
                    plotsel.Enddate = endDate;
                    plotsel.SelectAllSymbols();
                    if (plotsel.ShowDialog() == DialogResult.OK)
                    {
                        sc = plotsel.Sc;
                        endDate = plotsel.Enddate;
                        startDate = plotsel.Startdate;
                        DifGenerator difgen = new DifGenerator();
                        LogFilters filterhelper = new LogFilters();
                        difgen.SetFilters(filterhelper.GetFiltersFromRegistry());
                        difgen.LowAFR = m_appSettings.WidebandLowAFR / 1000;
                        difgen.HighAFR = m_appSettings.WidebandHighAFR / 1000;
                        difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage / 1000;
                        difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage / 1000;
                        difgen.WidebandSymbol = m_appSettings.WidebandLambdaSymbol;
                        difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;
                        difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                        try
                        {
                            if (difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, true))
                            {
                                //difgen.ConvertFileToDif(filename, sc, startDate, endDate, false, false);
                                StartLogWorksWithCurrentFile(Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".dif");
                            }
                            else
                            {
                                frmInfoBox info = new frmInfoBox("No data was found to export!");
                            }
                        }
                        catch (Exception expE2)
                        {
                            Console.WriteLine(expE2.Message);
                        }
                    }
                    TimeSpan ts = new TimeSpan(endDate.Ticks - startDate.Ticks);
                }
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }
        }
Ejemplo n.º 20
0
 public bool Contains(SymbolHelper value)
 {
     // If value is not of type Int16, this will return false.
     return (List.Contains(value));
 }
Ejemplo n.º 21
0
 private void ctrlRealtime1_onAddSymbolToMonitorList(object sender, ctrlRealtime.MapDisplayRequestEventArgs e)
 {
     // User added a symbol... maybe we need to keep track of these symbol ourselves and store it as a usercollection
     bool _fnd = false;
     foreach (Trionic5Tools.SymbolHelper sh in m_RealtimeUserSymbols)
     {
         if (sh.Varname == e.MapName)
         {
             _fnd = true;
         }
     }
     if (!_fnd)
     {
         Trionic5Tools.SymbolHelper shnew = new Trionic5Tools.SymbolHelper();
         shnew.Varname = e.MapName;
         shnew.Flash_start_address = m_trionicFileInformation.GetSymbolAddressFlash(e.MapName);
         shnew.Length = m_trionicFileInformation.GetSymbolLength(e.MapName);
         shnew.Start_address = m_trionicFileInformation.GetSymbolAddressSRAM(e.MapName);
         shnew.UserCorrectionFactor = e.CorrectionFactor;
         shnew.UserCorrectionOffset = e.CorrectionOffset;
         shnew.UseUserCorrection = e.UseUserCorrection;
         m_RealtimeUserSymbols.Add(shnew);
         _ecuConnection.AddSymbolToWatchlist(shnew, false);
         ctrlRealtime1.SetRealtimeSymbollist(m_RealtimeUserSymbols);
     }
 }
Ejemplo n.º 22
0
        public ctrlRealtime()
        {
            InitializeComponent();
            LoadExtraMeasurements();
            SymbolCollection sc = new SymbolCollection();
            SymbolHelper sh_fuel = new SymbolHelper();
            sh_fuel.Varname = "Insp_mat!";
            sh_fuel.Helptext = "Main fuel map";
            sc.Add(sh_fuel);
            SymbolHelper sh_korr = new SymbolHelper();
            //<GS-29112010> different for T5.2

            sh_korr.Varname = "Adapt_korr!";
            sh_korr.Helptext = "Fuel adaption";
            sc.Add(sh_korr);

            SymbolHelper sh_fuel_mut = new SymbolHelper();
            sh_fuel_mut.Varname = "FuelAdjustmentMap";
            sh_fuel_mut.Helptext = "Autotune fuel";
            sc.Add(sh_fuel_mut);
            SymbolHelper sh_knock = new SymbolHelper();
            sh_knock.Varname = "Fuel_knock_mat!";
            sh_knock.Helptext = "Knock fuel map";
            sc.Add(sh_knock);
            SymbolHelper sh_injconst = new SymbolHelper();
            sh_injconst.Varname = "Inj_konst!";
            sh_injconst.Helptext = "Injector constant";
            sc.Add(sh_injconst);
            btnMapEdit.Relevantsymbols = sc;
            try
            {
                sndplayer = new System.Media.SoundPlayer();
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }
        }
Ejemplo n.º 23
0
        //string skinMask = "Skin: ";
        /// <summary>
        /// InitSkins: Initialiseer de skin engine om het voor de gebruiker mogelijk te maken
        /// om een skin te kiezen voor de user interface
        /// </summary>
        void InitSkins()
        {
            ribbonControl1.ForceInitialize();
            BarButtonItem item;
            int skinCount = 0;
            DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.BonusSkins).Assembly);
            DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.OfficeSkins).Assembly);
            Trionic5Tools.SymbolCollection symcol = new Trionic5Tools.SymbolCollection();
            foreach (DevExpress.Skins.SkinContainer cnt in DevExpress.Skins.SkinManager.Default.Skins)
            {
                Trionic5Tools.SymbolHelper sh = new Trionic5Tools.SymbolHelper();
                sh.Varname = cnt.SkinName;
                symcol.Add(sh);
            }
            symcol.SortColumn = "Varname";
            symcol.SortingOrder = Trionic5Tools.GenericComparer.SortOrder.Ascending;
            symcol.Sort();
            foreach(Trionic5Tools.SymbolHelper sh in symcol)
            {
                item = new BarButtonItem();
                item.Caption = sh.Varname;
                BarItemLink il = rbnPageSkins.ItemLinks.Add(item);
                if ((skinCount++ % 3) == 0) il.BeginGroup = true;

                item.ItemClick += new ItemClickEventHandler(OnSkinClick);
            }
            try
            {
                if (m_appSettings.Skinname != string.Empty)
                {
                    if (IsChristmasTime())
                    {
                        // set chrismas skin
                        DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Xmas 2008 Blue"); // don't save
                    }
                    else if (IsHalloweenTime())
                    {
                        // set Halloween skin
                        DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Pumpkin"); // don't save
                    }
                    else if (IsValetineTime())
                    {
                        DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Valentine"); // don't save
                    }
                    else
                    {
                        DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(m_appSettings.Skinname);
                    }
                }
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }
            SetToolstripTheme();
        }
Ejemplo n.º 24
0
        private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            // Stop monitoring if session is active
            ResizeControls();
            bool _loggingWasActive = false;

            if (m_loggingActive)
            {
                _loggingWasActive = m_loggingActive;
                m_loggingActive = false;
            }
            if (_EnableAdvancedMode) btnMapEdit.Visible = true;
            digitalDisplayControl7.Visible = false;

            type = RealtimeMonitoringType.Fuel;
            SymbolCollection sc = new SymbolCollection();
            // notify parent of changed tabpage, the realtime stuff should be filled differently in that case
            if (e.Page.Text == xtraTabPage1.Text)
            {
                type = RealtimeMonitoringType.Fuel;
                // fill with fuel map
                SymbolHelper sh_fuel = new SymbolHelper();
                sh_fuel.Varname = "Insp_mat!";
                sh_fuel.Helptext = "Main fuel map";
                sc.Add(sh_fuel);
                SymbolHelper sh_korr = new SymbolHelper();
                sh_korr.Varname = "Adapt_korr!";
                sh_korr.Helptext = "Fuel adaption";
                sc.Add(sh_korr);
                SymbolHelper sh_fuel_mut = new SymbolHelper();
                sh_fuel_mut.Varname = "FuelAdjustmentMap";
                sh_fuel_mut.Helptext = "Autotune fuel";
                sc.Add(sh_fuel_mut);
                SymbolHelper sh_knock = new SymbolHelper();
                sh_knock.Varname = "Fuel_knock_mat!";
                sh_knock.Helptext = "Knock fuel map";
                sc.Add(sh_knock);
                SymbolHelper sh_injconst = new SymbolHelper();
                sh_injconst.Varname = "Inj_konst!";
                sh_injconst.Helptext = "Injector constant";
                sc.Add(sh_injconst);
                btnMapEdit.Relevantsymbols = sc;
            }
            else if (e.Page.Text == xtraTabPage2.Text)
            {
                type = RealtimeMonitoringType.Ignition;
                // fill with ignition maps
                SymbolHelper sh_ign = new SymbolHelper();
                sh_ign.Varname = "Ign_map_0!";
                sh_ign.Helptext = "Main ignition map";
                sc.Add(sh_ign);
                SymbolHelper sh_ignwarmup = new SymbolHelper();
                sh_ignwarmup.Varname = "Ign_map_4!";
                sh_ignwarmup.Helptext = "Warmup ignition map";
                sc.Add(sh_ignwarmup);
                SymbolHelper sh_ignknock = new SymbolHelper();
                sh_ignknock.Varname = "Ign_map_2!";
                sh_ignknock.Helptext = "Knock ignition map";
                sc.Add(sh_ignknock);
                btnMapEdit.Relevantsymbols = sc;
            }
            else if (e.Page.Text == xtraTabPage3.Text)
            {
                type = RealtimeMonitoringType.Boost;
                SymbolHelper sh_boostrequest = new SymbolHelper();
                sh_boostrequest.Varname = "Tryck_mat!";
                sh_boostrequest.Helptext = "Boost request map";
                sc.Add(sh_boostrequest);
                SymbolHelper sh_regkonmat = new SymbolHelper();
                sh_regkonmat.Varname = "Reg_kon_mat!";
                sh_regkonmat.Helptext = "Boost bias map";
                sc.Add(sh_regkonmat);
                SymbolHelper sh_pfact = new SymbolHelper();
                sh_pfact.Varname = "P_fors!";
                sh_pfact.Helptext = "P factors";
                sc.Add(sh_pfact);
                SymbolHelper sh_ifact = new SymbolHelper();
                sh_ifact.Varname = "I_fors!";
                sh_ifact.Helptext = "I factors";
                sc.Add(sh_ifact);
                SymbolHelper sh_dfact = new SymbolHelper();
                sh_dfact.Varname = "D_fors!";
                sh_dfact.Helptext = "D factors";
                sc.Add(sh_dfact);
                btnMapEdit.Relevantsymbols = sc;
            }
            else if (e.Page.Text == xtraTabPage4.Text)
            {
                type = RealtimeMonitoringType.Knock;
                SymbolHelper sh_knock_ref = new SymbolHelper();
                sh_knock_ref.Varname = "Knock_ref_matrix!";
                sh_knock_ref.Helptext = "Knock sensitivity";
                sc.Add(sh_knock_ref);
                SymbolHelper sh_knock_count = new SymbolHelper();
                sh_knock_count.Varname = "Knock_count_map";
                sh_knock_count.Helptext = "Knock counter map";
                sc.Add(sh_knock_count);
                SymbolHelper sh_ignknock = new SymbolHelper();
                sh_ignknock.Varname = "Ign_map_2!";
                sh_ignknock.Helptext = "Knock ignition map";
                sc.Add(sh_ignknock);
                SymbolHelper sh_knock = new SymbolHelper();
                sh_knock.Varname = "Fuel_knock_mat!";
                sh_knock.Helptext = "Knock fuel map";
                sc.Add(sh_knock);

                btnMapEdit.Relevantsymbols = sc;
            }
            else if (e.Page.Text == xtraTabPage5.Text)
            {
                type = RealtimeMonitoringType.Dashboard;
                btnMapEdit.Relevantsymbols = sc;

            }
            else if (e.Page.Text == xtraTabPage6.Text)
            {
                type = RealtimeMonitoringType.Settings;

                btnMapEdit.Relevantsymbols = sc;

            }
            else if (e.Page.Text == xtraTabPage7.Text)
            {
                type = RealtimeMonitoringType.Userdefined;
                // only show symbol that are in the watchlist
                // clear the map, it will be filled by itself
                System.Data.DataTable dtnew = new System.Data.DataTable();
                if (gridControl4.DataSource == null)
                {
                    dtnew.TableName = "RTSymbols";
                    dtnew.Columns.Add("SYMBOLNAME");
                    dtnew.Columns.Add("MINVALUE", Type.GetType("System.Double")); // autosense max and min!
                    dtnew.Columns.Add("MAXVALUE", Type.GetType("System.Double"));
                    dtnew.Columns.Add("VALUE", Type.GetType("System.Double"));
                    dtnew.Columns.Add("PEAK", Type.GetType("System.Double"));
                    gridControl4.DataSource = dtnew;
                }
                btnMapEdit.Relevantsymbols = sc;
            }
            else if (e.Page.Text == xtraTabPage8.Text)
            {
                type = RealtimeMonitoringType.EngineStatus;
                btnMapEdit.Relevantsymbols = sc;
            }
            else if (e.Page.Text == xtraTabPage9.Text)
            {
                type = RealtimeMonitoringType.OnlineGraph;
                btnMapEdit.Relevantsymbols = sc;
            }
            else if (e.Page.Text == tabAutoTuneIgnition.Text)
            {
                type = RealtimeMonitoringType.AutotuneIgnition;
            }
            else if (e.Page.Text == tabAutoTune.Text)
            {
                type = RealtimeMonitoringType.AutotuneFuel;
                btnMapEdit.Visible = false;
                digitalDisplayControl7.Visible = true;
            }
            else if (e.Page.Text == tabUserMaps.Text)
            {
                type = RealtimeMonitoringType.UserMaps;
                btnMapEdit.Relevantsymbols = sc;

                // load the grid
                DataTable dt = new DataTable();
                dt.TableName = "UserMaps";
                dt.Columns.Add("Mapname");
                dt.Columns.Add("Description");
                if (File.Exists(Application.StartupPath + "\\UserMaps.xml"))
                {
                    dt.ReadXml(Application.StartupPath + "\\UserMaps.xml");
                }
                /*else
                {
                    dt.Columns.Add("Mapname");
                    dt.Columns.Add("Description");
                }*/
                gridControl5.DataSource = dt;

            }
            if (e.PrevPage.Text == tabUserMaps.Text)
            {
                // save
                if (gridControl5.DataSource != null)
                {
                    DataTable dt = (DataTable)gridControl5.DataSource;
                    dt.WriteXml(Application.StartupPath + "\\UserMaps.xml");
                }
            }
            if (onMonitorTypeChanged != null)
            {
                // disable all controls in the bottom to indicate we don't have data for them at this point.
                // next, when data is received for one of the controls, enable them again
                DisableGenericControls();

                onMonitorTypeChanged(this, new RealtimeMonitoringEventArgs(type));

            }

            if (_loggingWasActive)
            {
                m_loggingActive = true;
                m_logfileName = DetermineNewLogFileName();
            }
        }
Ejemplo n.º 25
0
 public int Add(SymbolHelper value)
 {
     return(List.Add(value));
 }