//----------------------------------------------------------------------- // // Copyright © 2012 Nils Hammar. All rights reserved. // //----------------------------------------------------------------------- /* * Software to access vehicle information via the OBD-II connector. * * Copyright © 2012 Nils Hammar * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Alternative licensing is possible, see the licensing document. * * The above text may not be removed or modified. */ namespace SharedObjects.Misc { using System; using System.Collections.Generic; /// /// Container class containing classes used when storing data into XML files and retrieving data from XML files. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1052:StaticHolderTypesShouldBeSealed", Justification = "Used for XML data, can't be static.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1053:StaticHolderTypesShouldNotHaveConstructors", Justification = "Used for XML data, can't be static.")] public class XmlClass { /// /// List of capabilities a vehicle can have that's outside OBD-II standard. /// public static readonly string[] capabilities = { "SSM - Subaru Select Monitor", "VC1 - Volvo CAN-bus Workaround", }; /// /// Prevents a default instance of the class from being created. /// private XmlClass() { } /// /// For the modes 0x00 to 0xff. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class unititem { /// /// Gets or sets Text to be displayed. E.g. '°C'. /// public string name { get; set; } /// /// Gets or sets Description text for item. /// public string description { get; set; } /// /// Gets or sets Category for unit. 0 = All modes, 1=Metric mode, 2=Imperial mode. /// public int category { get; set; } /// /// Gets or sets a value indicating whether item is protected against deletion. /// public bool secured { get; set; } } /// /// For the modes 0x00 to 0xff. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class modeitem { /// /// Gets or sets Mode for item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint mode_int { get; set; } /// /// Gets or sets Description text for item. /// public string name { get; set; } /// /// Gets or sets a value indicating whether Secured against delete. /// public bool secured { get; set; } /// /// Gets or sets Description text for item. /// public string vehicle { get; set; } /// /// Gets or sets ID for PID group item in decimal form. /// public int pidgroupid { get; set; } } /// /// Gauge record item /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class gaugeitem { /// /// Gets or sets The number of the gauge. /// public uint gaugeNumber { get; set; } /// /// Gets or sets Description text for item. /// public string gaugetext { get; set; } /// /// Gets or sets ID for item in decimal form. /// public int pidgroupid { get; set; } /// /// Gets or sets Address or PID for item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint pid_int { get; set; } /// /// Gets or sets Unit for value. /// public string sensor_unit { get; set; } /// /// Gets or sets Data Offset (byte in data record) /// public uint sensor_offset { get; set; } /// /// Gets or sets Data Offset (byte in data record) /// public int sensor_startbit { get; set; } /// /// Gets or sets How many steps the scale shall be divided into /// public uint majorScaleSteps { get; set; } /// /// Gets or sets How many steps between each major step /// public uint minorScaleSteps { get; set; } /// /// Gets or sets What to divide the value with before display in gauge. /// public float divisor { get; set; } /// /// Gets or sets Description text for item. /// public string digitalGaugetext { get; set; } /// /// Gets or sets ID for item in decimal form. /// public int digitalPidgroupid { get; set; } /// /// Gets or sets Address or PID for item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint digitalPid_int { get; set; } /// /// Gets or sets Unit for value. /// public string digitalSensor_unit { get; set; } /// /// Gets or sets Data Offset (byte in data record) /// public uint digitalSensor_offset { get; set; } /// /// Gets or sets Data Offset (byte in data record) /// public int digitalSensor_startbit { get; set; } /// /// Gets or sets How many steps the scale shall be divided into /// public string digitalFormat { get; set; } /// /// Gets or sets What to divide the value with before display in gauge. /// public float digitalDivisor { get; set; } } /// /// Gauge record item /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class telltaleitem { /// /// Gets or sets The number of the gauge. /// public uint telltaleGroupNumber { get; set; } /// /// Gets or sets The number of the gauge. /// public int telltalePriority { get; set; } /// /// Gets or sets Description text for item. /// public string telltaletext { get; set; } /// /// Gets or sets icon file name. /// public string telltaleicon { get; set; } /// /// Gets or sets ID for item in decimal form. /// public int pidgroupid { get; set; } /// /// Gets or sets Address or PID for item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint pid_int { get; set; } /// /// Gets or sets Unit for value. /// public string sensor_unit { get; set; } /// /// Gets or sets Data Offset (byte in data record) /// public uint sensor_offset { get; set; } /// /// Gets or sets sensor bit number. /// public int sensor_bit { get; set; } /// /// Gets or sets primary color. /// public string primaryColor { get; set; } /// /// Gets or sets secondary color. /// public string secondaryColor { get; set; } /// /// Gets or sets secondary color. /// public string flashColor { get; set; } /// /// Get the hash code for the item. /// /// Computed hash code. public override int GetHashCode() { int hc = this.pidgroupid.GetHashCode(); hc = hc << 7 | hc >> 25; hc ^= this.pid_int.GetHashCode(); hc = hc << 7 | hc >> 25; hc ^= this.sensor_offset.GetHashCode(); hc = hc << 7 | hc >> 25; hc ^= this.sensor_bit.GetHashCode(); return hc; } /// /// Compare objects. /// /// Object to compare with. /// 'true' if equal. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Reviewed.")] public override bool Equals(object obj) { if (obj is XmlClass.telltaleitem) { XmlClass.telltaleitem item = (XmlClass.telltaleitem)obj; return (this.pidgroupid == item.pidgroupid && this.pid_int == item.pid_int && this.sensor_offset == item.sensor_offset && this.sensor_bit == item.sensor_bit); } return false; } } /// /// Grouping of PID list and other lists so it can be re-used /// in different contexts. E.g. for both mode 0x01 and 0x02. /// How each mode uses the list is depending on the implementation /// of the mode. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class pidgroup { /// /// Gets or sets ID for item in decimal form. /// public int id { get; set; } /// /// Gets or sets Description text for item. /// public string name { get; set; } /// /// Gets or sets Default Mode for item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint mode_int { get; set; } /// /// Gets or sets a value indicating whether item has mapping of supported functions. /// public bool hasMap { get; set; } /// /// List of PID:s. /// private List pidlst = new List(); /// /// Gets or sets PID list. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List pids { get { return this.pidlst; } set { this.pidlst = value; } } /// /// Sort the PIDs. /// public void sortPids() { this.pidlst.Sort(Utils.pidlist_sorter); } /// /// List of PIDs (and TIDs, Addresses etc.) /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class pidlist { /// /// Gets or sets Description text for item. /// public string name { get; set; } /// /// Gets or sets Address or PID for item in hex. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint pid_int { get; set; } /// /// Gets or sets number of bytes for PID. /// This is used for SSM when data is more than one byte, default shall be one byte. /// public uint pid_bytes { get; set; } /// /// Gets or sets a value indicating whether data for this PID can be plotted. /// public bool canPlot { get; set; } /// /// Gets or sets Height for graph when plotting. Default 150, range 60 to 800. /// public uint plotHeight { get; set; } /// /// Gets or sets a value indicating whether To control special handling of PID maps in the application. /// public bool pidIsMap { get; set; } /// /// Gets or sets refresh interval value. /// public string refresh { get; set; } /// /// List of sensors. /// private List sensor = new List(); /// /// Gets or sets Sensors. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List sensors { get { return this.sensor; } set { this.sensor = value; } } /// /// Sort the sensor list. /// public void sortSensors() { this.sensor.Sort(Utils.sensordata_sorter); } /// /// Configuration data for each sensor corresponding to the PID. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class sensordata { /// /// Gets or sets ID of sensor. /// public uint id { get; set; } /// /// Gets or sets Description text for value. /// public string name { get; set; } /// /// Gets or sets Unit for value. /// public string unit { get; set; } /// /// Gets or sets Data Offset (byte in data record) /// public uint offset { get; set; } /// /// Gets or sets Number of bytes used. /// public uint count { get; set; } /// /// Gets or sets Start bit in byte for value. /// public string startbit { get; set; } /// /// Gets or sets End bit in byte for value. /// public string endbit { get; set; } /// /// Gets or sets Offset at calculation, e.g. -40 for temperature. /// public double scaleoffset { get; set; } /// /// Gets or sets Factor to multiply with after application of offset. /// public double scalefactor { get; set; } /// /// Gets or sets Max value when presenting in graph. /// public double presentation_max { get; set; } /// /// Gets or sets Min value when presenting in graph. /// public double presentation_min { get; set; } /// /// Gets or sets How the value shall be formatted, empty uses 0.000. /// public string sensorPresentation_format { get; set; } /// /// Gets or sets Max value of red zone in graph. Disabled when equal to red_zone_min. /// public double red_zone_max { get; set; } /// /// Gets or sets Min value of red zone in graph. /// public double red_zone_min { get; set; } /// /// Gets or sets Max value of second red zone in graph. Disabled when equal to red_zone_min. /// public double red2_zone_max { get; set; } /// /// Gets or sets Min value of second red zone in graph. /// public double red2_zone_min { get; set; } /// /// Gets or sets Max value of yellow zone in graph. Disabled when equal to yellow_zone_min. /// public double yellow_zone_max { get; set; } /// /// Gets or sets Min value of yellow zone in graph. /// public double yellow_zone_min { get; set; } /// /// Gets or sets Max value of blue zone in graph. Disabled when equal to blue_zone_min. /// public double blue_zone_max { get; set; } /// /// Gets or sets Min value of blue zone in graph. /// public double blue_zone_min { get; set; } /// /// Gets or sets Max value of green zone in graph. Disabled when equal to green_zone_min. /// public double green_zone_max { get; set; } /// /// Gets or sets Min value of green zone in graph. /// public double green_zone_min { get; set; } /// /// Gets or sets Color to plot with, leave empty to disable plotting. /// public string plotColor { get; set; } } } } /// /// Vehicle record item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class vehicle { /// /// Gets or sets ID of vehicle. (Internal to application) /// public int id { get; set; } /// /// Gets or sets Name of vehicle. /// public string name { get; set; } /// /// Gets or sets Brand of vehicle. /// public string brand { get; set; } /// /// Gets or sets Vehicle Model. /// public string model { get; set; } /// /// Gets or sets Protocol for vehicle. /// public string protocol { get; set; } /// /// Gets or sets Communication speed for vehicle. /// public uint speed { get; set; } /// /// Gets or sets Address of tester for the vehicle. /// public string testeraddress { get; set; } /// /// Gets or sets Name of OBD codes file specific for the vehicle. /// public string obdcodefile { get; set; } /// /// Gets or sets Address bits for ISO15765 vehicles. /// public int addressbits { get; set; } /// /// Gets or sets a value indicating whether the vehicle record is protected against deletion. /// public bool secured { get; set; } /// /// Gets or sets a value indicating whether checksum shall be added on ISO9141 vehicle communication. /// public bool checksum { get; set; } /// /// Gets or sets If a certain initialization procedure is needed. /// public int initprocedure { get; set; } /// /// List of Tx addresses. /// private List txa = new List(); /// /// Gets or sets Tx address list. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List txaddrlist { get { return this.txa; } set { this.txa = value; } } /// /// List of Rx addresses. /// private List rxa = new List(); /// /// Gets or sets Rx address list. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List rxaddrlist { get { return this.rxa; } set { this.rxa = value; } } /// /// Sort the TX address list. /// public void sortTxAddrList() { this.txa.Sort(Utils.addrlist_sorter); } /// /// Sort the RX address list. /// public void sortRxAddrList() { this.rxa.Sort(Utils.addrlist_sorter); } /// /// List of active message flags for vehicle. /// private List msgflg = new List(); /// /// Gets or sets Message flags. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List msgflags { get { return this.msgflg; } set { this.msgflg = value; } } /// /// List of active connection flags for vehicle. /// private List connflg = new List(); /// /// Gets or sets Connection flags. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List connflags { get { return this.connflg; } set { this.connflg = value; } } /// /// ECU list for vehicle. /// private List ecuList = new List(); /// /// Gets or sets ECU list. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List ecus { get { return this.ecuList; } set { this.ecuList = value; } } /// /// Sort the ECU list. /// public void sortEcuList() { this.ecuList.Sort(Utils.eculist_sorter); } /// /// List of config parameters for vehicle. /// private List conf = new List(); /// /// Gets or sets Config parameters. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List config { get { return this.conf; } set { this.conf = value; } } /// /// List of PID groups for vehicle. /// private List pidgrps = new List(); /// /// Gets or sets Pid groups. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List pidgroups { get { return this.pidgrps; } set { this.pidgrps = value; } } /// /// List of capabilities for vehicle. /// private List caplist = new List(); /// /// Gets or sets Capabilities. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List capabilities { get { return this.caplist; } set { this.caplist = value; } } /// /// Address list item class. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class addrlist { /// /// Gets or sets Node Address. /// public string address { get; set; } /// /// Gets or sets a value indicating whether record is Broadcast/Functional address flag. /// public bool broadcast { get; set; } } /// /// Flags item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class flags { /// /// Gets or sets Flag value. /// public string flag { get; set; } } /// /// ECU item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class ecuData { /// /// Gets or sets ECU ID (Address) /// public string id { get; set; } /// /// Gets or sets Name of ECU. /// public string name { get; set; } } /// /// Config parameters item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class configpars { /// /// Gets or sets Config parameter name. /// public string name { get; set; } /// /// Gets or sets Config parameter value. /// public string value { get; set; } } /// /// PID group item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class pidgroup { /// /// Gets or sets ID for item in decimal form. /// public int id { get; set; } /// /// Gets or sets Description text for item. /// public string name { get; set; } /// /// Gets or sets Mode for item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint mode_int { get; set; } } /// /// Capability item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class capability { /// /// Gets or sets Capability name. /// public string name { get; set; } } } /// /// Communication speed record. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class commspeed { /// /// Gets or sets Name of speed. /// public string name { get; set; } /// /// Gets or sets BPS value for speed. /// public uint bps { get; set; } /// /// Gets or sets a value indicating whether record is common default value (obsoleted) /// public bool defaultval { get; set; } /// /// Gets or sets a value indicating whether record is Default value for J1850 /// public bool defaultJ1850 { get; set; } /// /// Gets or sets a value indicating whether record is Default value for ISO9141 /// public bool defaultISO9141 { get; set; } /// /// Gets or sets a value indicating whether record is Default value for ISO15765 /// public bool defaultISO15765 { get; set; } /// /// Gets or sets a value indicating whether record is Valid value for J1850 /// public bool validJ1850 { get; set; } /// /// Gets or sets a value indicating whether record is Valid value for ISO9141 /// public bool validISO9141 { get; set; } /// /// Gets or sets a value indicating whether record is Valid value for ISO15765 /// public bool validISO15765 { get; set; } /// /// Get string representation. /// /// String representation of item public override string ToString() { return this.name; } } /// /// For definition of parameters supported by SET/GET config. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class parameteritem : IComparable, IEqualityComparer { /// /// Gets or sets ID of parameter. /// public uint id { get; set; } /// /// Gets or sets Name of parameter. /// public string name { get; set; } /// /// Gets or sets Parameter description. /// public string description { get; set; } /// /// Gets or sets the presentation type to use for the value. /// public string presentationType { get; set; } /// /// Gets or sets Permitted min value. /// public uint min { get; set; } /// /// Gets or sets Permitted max value. /// public uint max { get; set; } /// /// Gets or sets List of protocol ids this parameter is valid for. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Reviewed.")] public int[] protocols { get; set; } /// /// Gets or sets a value indicating whether record is secured against deletion. /// public bool secured { get; set; } /// /// Implementation of equals. /// /// Item 1 /// Item 2 /// 'true' if equal. public static bool operator ==(parameteritem r1, parameteritem r2) { if (((object)r1) == null && ((object)r2) == null) { return true; } if (((object)r1) == null) { return false; } if (((object)r2) == null) { return false; } return r1.Equals(r2); } /// /// Implementation of not equals. /// /// Item 1 /// Item 2 /// 'true' if not equal. public static bool operator !=(parameteritem r1, parameteritem r2) { return !(r1 == r2); } /// /// Implementation of less than. /// /// Item 1 /// Item 2 /// 'true' if less than. public static bool operator <(parameteritem r1, parameteritem r2) { if (((object)r1) == null && ((object)r2) == null) { return false; } if (((object)r1) == null) { return true; } if (((object)r2) == null) { return false; } return (r1.CompareTo(r2) < 0); } /// /// Implementation of greater than. /// /// Item 1 /// Item 2 /// 'true' if greater than. public static bool operator >(parameteritem r1, parameteritem r2) { if (((object)r1) == null && ((object)r2) == null) { return false; } if (((object)r1) == null) { return false; } if (((object)r2) == null) { return true; } return (r1.CompareTo(r2) > 0); } /// /// Compare with... /// /// Object to compare with. /// Result of compare public int CompareTo(parameteritem obj) { if (obj == null) { return 1; } int res = 0; if (this.id < obj.id) { res = -1; } if (this.id > obj.id) { res = 1; } return res; } /// /// Check if objects are equal. /// /// Object 1. /// Object 2. /// 'true' if equal public bool Equals(parameteritem obj1, parameteritem obj2) { if (obj1 == null && obj2 == null) { return true; } if (obj1 == null) { return false; } if (obj2 == null) { return false; } return obj1.id == obj2.id; } /// /// Get hashcode for object. /// /// Object to get hashcode for. /// Hashcode value. public int GetHashCode(parameteritem obj) { if (obj == null) { return 0; } return obj.GetHashCode(); } /// /// Get hashcode for object. /// /// Hashcode value. public override int GetHashCode() { return (int)this.id; } /// /// Check if objects are equal. /// /// Object to compare with. /// 'true' if equal. public override bool Equals(object obj) { if (obj != null) { parameteritem o2 = (parameteritem)obj; return this.id == o2.id; } return false; } } /// /// Preference item /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] [Serializable] public class preference { /// /// Gets or sets Name of preference. /// public string name { get; set; } /// /// Gets or sets Preference value. /// public string value { get; set; } /// /// Get hashcode for object. /// /// Calculated hash code. public override int GetHashCode() { return this.name != null ? this.name.GetHashCode() : 0; } /// /// Test if equals to object. /// /// Object to compare with. /// 'true' if equals. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Reviewed, intentional.")] public override bool Equals(object obj) { if (obj is preference) { preference pref = (preference)obj; return (this.name == pref.name); } return false; } } /// /// Filter record. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class filter { /// /// Gets or sets Name of filter record. /// public string name { get; set; } /// /// List of filter items. /// private List fitems = new List(); /// /// Gets or sets Filter item list. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List filteritems { get { return this.fitems; } set { this.fitems = value; } } /// /// Filter list items. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class filteritem { /// /// Gets or sets ID of item. /// public uint id { get; set; } /// /// Gets or sets Protocol for filter. /// public int protocol { get; set; } /// /// Gets or sets Type of filter. /// public uint type { get; set; } /// /// Gets or sets Filter Mask. /// public uint mask { get; set; } /// /// Gets or sets Filter Pattern. /// public uint pattern { get; set; } /// /// Gets or sets Filter Flow value. /// public uint flow { get; set; } /// /// Gets or sets Filter Datasize. /// public uint datasize { get; set; } /// /// Gets or sets Filter flags. /// public uint flags { get; set; } } } /// /// PID Selection record. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class pidselection { /// /// Gets or sets PID Selection description. /// public string description { get; set; } /// /// List of PID groups. /// private List pidgrps = new List(); /// /// Gets or sets PID group list. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List pidgroups { get { return this.pidgrps; } set { this.pidgrps = value; } } /// /// Pid Group item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class selectionpidgroup { /// /// Gets or sets Pid group /// public XmlClass.pidgroup pidGroup { get; set; } /// /// PID items list. /// private List piditems = new List(); /// /// Gets or sets PID items. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Used for XML data, can't be readonly.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Used for XML data, can't be readonly.")] public List pids { get { return this.piditems; } set { this.piditems = value; } } /// /// PID item /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class pid { /// /// Gets or sets PID id. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint pid_int { get; set; } /// /// Gets or sets a value indicating whether PID state is active. /// public bool active { get; set; } } } } /// /// Icon item /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class icon { /// /// Gets or sets Icon Key. /// public string key { get; set; } /// /// Gets or sets Icon File. /// public string file { get; set; } /// /// Gets or sets Icon File. /// public string description { get; set; } } /// /// Mode + PID item /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")] public class selectionModePid { /// /// List of filter items. /// private List addressList = new List(); /// /// Gets or sets List of destination ECU addresses for message. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Justification = "Reviewed, intentional")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Reviewed, intentional")] public List addrList { get { return this.addressList; } set { this.addressList = value; } } /// /// Gets or sets Mode for item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint mode_int { get; set; } /// /// Gets or sets PID id. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed.")] public uint pid_int { get; set; } /// /// Gets or sets selected plot group. /// public int plotGroup { get; set; } /// /// One address item. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional")] public class addressItem { /// /// Gets or sets address field. /// public uint address { get; set; } } } } }