PlatformVersion.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2018-2022, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _DATASPEED_ULC_CAN_PLATFORM_VERSION_H
36 #define _DATASPEED_ULC_CAN_PLATFORM_VERSION_H
37 
38 // Module Version class
40 
41 namespace dataspeed_ulc_can
42 {
43 
44 // Vehicle platform enumeration
45 typedef enum {
46  P_FORD_CD4 = 0x00, // Lincoln MKZ, Ford Fusion/Mondeo
47  P_FORD_P5 = 0x01, // Ford F150
48  P_FORD_C1 = 0x02, // Ford Transit Connect
49  P_FORD_T6 = 0x03, // Ford Ranger
50  P_FORD_U6 = 0x04, // Lincoln Aviator
51  P_FORD_CD5 = 0x05, // Ford Edge, Lincoln Nautilus
52  P_FORD_GE1 = 0x06, // Ford Mustang Mach-E
53  P_FCA_RU = 0x10, // Chrysler Pacifica
54  P_FCA_WK2 = 0x11, // Jeep Grand Cherokee
55  P_POLARIS_GEM = 0x80, // Polaris GEM
56  P_POLARIS_RZR = 0x81, // Polaris RZR
57 } Platform;
58 
59 // Module type enumeration
60 typedef enum {
61  M_BPEC = 1, // Brake Pedal Emulator Combo
62  M_TPEC = 2, // Throttle Pedal Emulator Combo
63  M_STEER = 3, // CAN Steering and gateway
64  M_SHIFT = 4, // Shifting
65  M_ABS = 5, // ACC/AEB Braking
66  M_BOO = 6, // Brake-On-Off for ABS Braking
67  M_EPS = 7, // EPS Steering
68 } Module;
69 
70 static const char* platformToString(Platform x) {
71  switch (x) {
72  case P_FORD_CD4: return "FORD_CD4";
73  case P_FORD_P5: return "FORD_P5";
74  case P_FORD_C1: return "FORD_C1";
75  case P_FORD_T6: return "FORD_T6";
76  case P_FORD_U6: return "FORD_U6";
77  case P_FORD_CD5: return "FORD_CD5";
78  case P_FORD_GE1: return "FORD_GE1";
79  case P_FCA_RU: return "FCA_RU";
80  case P_FCA_WK2: return "FCA_WK2";
81  case P_POLARIS_GEM: return "POLARIS_GEM";
82  case P_POLARIS_RZR: return "POLARIS_RZR";
83  default: return "UNKNOWN";
84  }
85 }
86 
87 static const char* moduleToString(Module x) {
88  switch (x) {
89  case M_BPEC: return "BPEC ";
90  case M_TPEC: return "TPEC ";
91  case M_STEER: return "STEER";
92  case M_SHIFT: return "SHIFT";
93  case M_ABS: return "ABS ";
94  case M_BOO: return "BOO ";
95  case M_EPS: return "EPS ";
96  default: return "UNKNOWN";
97  }
98 }
99 
100 class PlatformVersion {
101 public:
102  PlatformVersion() : p((Platform)0), m((Module)0) {};
103  PlatformVersion(Platform _p, Module _m, ModuleVersion _v) : p(_p), m(_m), v(_v) {};
104  PlatformVersion(Platform _p, Module _m, uint16_t major, uint16_t minor, uint16_t build) : p(_p), m(_m), v(ModuleVersion(major, minor, build)) {};
105  bool operator< (const PlatformVersion& other) const { return (this->p == other.p) && (this->m == other.m) && (this->v < other.v); }
106  bool operator> (const PlatformVersion& other) const { return (this->p == other.p) && (this->m == other.m) && (this->v > other.v); }
107  bool operator<=(const PlatformVersion& other) const { return (this->p == other.p) && (this->m == other.m) && (this->v <= other.v); }
108  bool operator>=(const PlatformVersion& other) const { return (this->p == other.p) && (this->m == other.m) && (this->v >= other.v); }
109  bool operator==(const PlatformVersion& other) const { return (this->p == other.p) && (this->m == other.m) && (this->v == other.v); }
110  bool operator!=(const PlatformVersion& other) const { return (this->p == other.p) && (this->m == other.m) && (this->v != other.v); }
112 };
113 
114 static bool operator< (const PlatformVersion& x, const ModuleVersion& y) { return x.v < y; }
115 static bool operator> (const PlatformVersion& x, const ModuleVersion& y) { return x.v > y; }
116 static bool operator<=(const PlatformVersion& x, const ModuleVersion& y) { return x.v <= y; }
117 static bool operator>=(const PlatformVersion& x, const ModuleVersion& y) { return x.v >= y; }
118 static bool operator==(const PlatformVersion& x, const ModuleVersion& y) { return x.v == y; }
119 static bool operator!=(const PlatformVersion& x, const ModuleVersion& y) { return x.v != y; }
120 
121 } // namespace dataspeed_ulc_can
122 
123 #endif // _DATASPEED_ULC_CAN_PLATFORM_VERSION_H
124 
dataspeed_ulc_can::platformToString
static const char * platformToString(Platform x)
Definition: PlatformVersion.h:102
dataspeed_ulc_can::P_FORD_CD4
@ P_FORD_CD4
Definition: PlatformVersion.h:110
dataspeed_ulc_can::Module
Module
Definition: PlatformVersion.h:92
dataspeed_ulc_can
Definition: dispatch.h:39
dataspeed_ulc_can::P_POLARIS_GEM
@ P_POLARIS_GEM
Definition: PlatformVersion.h:119
dataspeed_ulc_can::operator>
static bool operator>(const PlatformVersion &x, const PlatformMap &map)
Definition: PlatformMap.h:142
dataspeed_ulc_can::operator<=
static bool operator<=(const PlatformVersion &x, const PlatformMap &map)
Definition: PlatformMap.h:143
dataspeed_ulc_can::M_BOO
@ M_BOO
Definition: PlatformVersion.h:98
dataspeed_ulc_can::PlatformVersion::operator!=
bool operator!=(const PlatformVersion &other) const
Definition: PlatformVersion.h:142
dataspeed_ulc_can::PlatformVersion::operator<=
bool operator<=(const PlatformVersion &other) const
Definition: PlatformVersion.h:139
dataspeed_ulc_can::operator!=
static bool operator!=(const PlatformVersion &x, const PlatformMap &map)
Definition: PlatformMap.h:146
dataspeed_ulc_can::P_POLARIS_RZR
@ P_POLARIS_RZR
Definition: PlatformVersion.h:120
dataspeed_ulc_can::PlatformVersion::v
ModuleVersion v
Definition: PlatformVersion.h:143
dataspeed_ulc_can::PlatformVersion::operator==
bool operator==(const PlatformVersion &other) const
Definition: PlatformVersion.h:141
dataspeed_ulc_can::P_FCA_RU
@ P_FCA_RU
Definition: PlatformVersion.h:117
dataspeed_ulc_can::PlatformVersion::operator<
bool operator<(const PlatformVersion &other) const
Definition: PlatformVersion.h:137
dataspeed_ulc_can::PlatformVersion::PlatformVersion
PlatformVersion()
Definition: PlatformVersion.h:134
dataspeed_ulc_can::PlatformVersion::operator>
bool operator>(const PlatformVersion &other) const
Definition: PlatformVersion.h:138
dataspeed_ulc_can::M_TPEC
@ M_TPEC
Definition: PlatformVersion.h:94
dataspeed_ulc_can::M_EPS
@ M_EPS
Definition: PlatformVersion.h:99
dataspeed_ulc_can::PlatformVersion
Definition: PlatformVersion.h:132
dataspeed_ulc_can::M_BPEC
@ M_BPEC
Definition: PlatformVersion.h:93
dataspeed_ulc_can::Platform
Platform
Definition: PlatformVersion.h:77
dataspeed_ulc_can::M_ABS
@ M_ABS
Definition: PlatformVersion.h:97
dataspeed_ulc_can::PlatformVersion::m
Module m
Definition: PlatformVersion.h:143
dataspeed_ulc_can::P_FORD_GE1
@ P_FORD_GE1
Definition: PlatformVersion.h:116
dataspeed_ulc_can::M_STEER
@ M_STEER
Definition: PlatformVersion.h:95
dataspeed_ulc_can::P_FCA_WK2
@ P_FCA_WK2
Definition: PlatformVersion.h:118
dataspeed_ulc_can::P_FORD_U6
@ P_FORD_U6
Definition: PlatformVersion.h:114
dataspeed_ulc_can::P_FORD_P5
@ P_FORD_P5
Definition: PlatformVersion.h:111
dataspeed_ulc_can::moduleToString
static const char * moduleToString(Module x)
Definition: PlatformVersion.h:119
dataspeed_ulc_can::ModuleVersion
Definition: ModuleVersion.h:83
dataspeed_ulc_can::M_SHIFT
@ M_SHIFT
Definition: PlatformVersion.h:96
dataspeed_ulc_can::PlatformVersion::p
Platform p
Definition: PlatformVersion.h:143
dataspeed_ulc_can::P_FORD_T6
@ P_FORD_T6
Definition: PlatformVersion.h:113
dataspeed_ulc_can::P_FORD_CD5
@ P_FORD_CD5
Definition: PlatformVersion.h:115
dataspeed_ulc_can::P_FORD_C1
@ P_FORD_C1
Definition: PlatformVersion.h:112
dataspeed_ulc_can::operator<
static bool operator<(const PlatformVersion &x, const PlatformMap &map)
Definition: PlatformMap.h:141
ModuleVersion.h
dataspeed_ulc_can::PlatformVersion::operator>=
bool operator>=(const PlatformVersion &other) const
Definition: PlatformVersion.h:140
dataspeed_ulc_can::operator==
static bool operator==(const PlatformVersion &x, const PlatformMap &map)
Definition: PlatformMap.h:145
dataspeed_ulc_can::operator>=
static bool operator>=(const PlatformVersion &x, const PlatformMap &map)
Definition: PlatformMap.h:144


dataspeed_ulc_can
Author(s): Micho Radovnikovich
autogenerated on Sat Dec 3 2022 03:34:49