CTRE Phoenix Pro C++ 23.0.12
DeviceIdentifier.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
10#include <cstdint>
11#include <sstream>
12#include <string>
13
14namespace ctre {
15namespace phoenixpro {
16namespace hardware {
17
19 {
20 public:
21 std::string network;
22 std::string model;
24 uint32_t deviceHash;
25
26 DeviceIdentifier() = default;
27 DeviceIdentifier(int deviceID, std::string model, std::string canbus) : network{std::move(canbus)},
28 model{std::move(model)},
30 deviceHash{networking::Wrappers::CompileDeviceHash(Context::ContextAPI, deviceID, this->model.c_str())}
31 {
32 }
33
34 std::string ToString() const
35 {
36 std::stringstream ss;
37 ss << model << " " << deviceID << " (" << network << ")";
38 return ss.str();
39 }
40 };
41
42}
43}
44}
enum _Context Context
@ ContextAPI
Definition: Context.h:11
Definition: DeviceIdentifier.hpp:19
DeviceIdentifier(int deviceID, std::string model, std::string canbus)
Definition: DeviceIdentifier.hpp:27
std::string model
Definition: DeviceIdentifier.hpp:22
int deviceID
Definition: DeviceIdentifier.hpp:23
std::string network
Definition: DeviceIdentifier.hpp:21
std::string ToString() const
Definition: DeviceIdentifier.hpp:34
uint32_t deviceHash
Definition: DeviceIdentifier.hpp:24
Definition: string_util.hpp:14