Made 'syncFromDevice' work again.
This commit is contained in:
@@ -27,12 +27,12 @@ windows
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
bc.cpp \
|
bc.cpp \
|
||||||
bcdatamanager.cpp \
|
bcdatamanager.cpp \
|
||||||
bcdatavalue.cpp \
|
bcdelegate.cpp \
|
||||||
bcdevicepanel.cpp \
|
bcdevicepanel.cpp \
|
||||||
bcitemdelegate.cpp \
|
|
||||||
bclegacy.cpp \
|
bclegacy.cpp \
|
||||||
bctoolbutton.cpp \
|
bctoolbutton.cpp \
|
||||||
bctransmitter.cpp \
|
bctransmitter.cpp \
|
||||||
|
bcvalue.cpp \
|
||||||
bcvaluemodel.cpp \
|
bcvaluemodel.cpp \
|
||||||
bcvaluetype.cpp \
|
bcvaluetype.cpp \
|
||||||
lib/can_drv_win.c \
|
lib/can_drv_win.c \
|
||||||
@@ -46,12 +46,12 @@ HEADERS += \
|
|||||||
bccandriver.h \
|
bccandriver.h \
|
||||||
bccandrivertinycan.h \
|
bccandrivertinycan.h \
|
||||||
bcdatamanager.h \
|
bcdatamanager.h \
|
||||||
bcdatavalue.h \
|
bcdelegate.h \
|
||||||
bcdevicepanel.h \
|
bcdevicepanel.h \
|
||||||
bcitemdelegate.h \
|
|
||||||
bcmainwindow.h \
|
bcmainwindow.h \
|
||||||
bctoolbutton.h \
|
bctoolbutton.h \
|
||||||
bctransmitter.h \
|
bctransmitter.h \
|
||||||
|
bcvalue.h \
|
||||||
bcvaluemodel.h \
|
bcvaluemodel.h \
|
||||||
bcvaluetype.h
|
bcvaluetype.h
|
||||||
|
|
||||||
|
|||||||
20
bc.h
20
bc.h
@@ -110,14 +110,7 @@ constexpr auto to_u(E e) noexcept {
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QLatin1StringView>
|
#include <QLatin1StringView>
|
||||||
|
|
||||||
namespace Consts {
|
|
||||||
using namespace Qt::Literals::StringLiterals;
|
|
||||||
// 1. Compile-Time Konstante (constexpr)
|
|
||||||
// 2. Kein Heap-Speicher (Zero Allocation)
|
|
||||||
// 3. Minimale Binary-Größe (1 Byte char) <- 8 Bit!
|
|
||||||
// Beste Performance, keine Allokation, Typ-Sicher
|
|
||||||
inline constexpr auto OrgName = "source::worx"_L1;
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct BC
|
struct BC
|
||||||
@@ -133,6 +126,17 @@ public:
|
|||||||
};
|
};
|
||||||
Q_ENUM(OpID)
|
Q_ENUM(OpID)
|
||||||
|
|
||||||
|
// __fix! flags draus machen ?
|
||||||
|
enum class State : uint8_t
|
||||||
|
{
|
||||||
|
Invalid,
|
||||||
|
Locked,
|
||||||
|
Failed,
|
||||||
|
InSync,
|
||||||
|
OK
|
||||||
|
};
|
||||||
|
Q_ENUM(State)
|
||||||
|
|
||||||
enum class ID : uint8_t
|
enum class ID : uint8_t
|
||||||
{
|
{
|
||||||
//{%Region Console}
|
//{%Region Console}
|
||||||
|
|||||||
812
bc.h.autosave
812
bc.h.autosave
@@ -1,812 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
|
|
||||||
BionxControl
|
|
||||||
Copyright © 2025 christoph holzheuer
|
|
||||||
christoph.holzheuer@gmail.com
|
|
||||||
|
|
||||||
Using:
|
|
||||||
|
|
||||||
mhs_can_drv.c
|
|
||||||
© 2011 - 2023 by MHS-Elektronik GmbH & Co. KG, Germany
|
|
||||||
Klaus Demlehner, klaus@mhs-elektronik.de
|
|
||||||
@see www.mhs-elektronik.de
|
|
||||||
|
|
||||||
Based on Bionx data type descriptions from:
|
|
||||||
|
|
||||||
BigXionFlasher USB V 0.2.4 rev. 97
|
|
||||||
© 2011-2013 by Thomas Koenig <info@bigxionflasher.org>
|
|
||||||
@see www.bigxionflasher.org
|
|
||||||
|
|
||||||
Bionx Bike Info
|
|
||||||
© 2018 Thorsten Schmidt (tschmidt@ts-soft.de)
|
|
||||||
@see www.ts-soft.de
|
|
||||||
|
|
||||||
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.
|
|
||||||
@see https://github.com/bikemike/bionx-bikeinfo
|
|
||||||
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BC_H
|
|
||||||
#define BC_H
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QObject> // Nötig für Q_GADGET/Q_ENUM Makros
|
|
||||||
|
|
||||||
//uint8_t;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Simple exception class
|
|
||||||
*/
|
|
||||||
|
|
||||||
class BCException : public std::runtime_error
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
BCException( const QString& what, const QString& param="" );
|
|
||||||
BCException( const QString& what, int errCode );
|
|
||||||
|
|
||||||
// das ist unsinn: exception werden nicht zwangsläufig im
|
|
||||||
// gui thread gefangen, das popup kann aber nur dort
|
|
||||||
// angezeigt werden.
|
|
||||||
//void popup() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace bc
|
|
||||||
{
|
|
||||||
[[maybe_unused]] constexpr static double UNLIMITED_SPEED_VALUE = 70; // Km/h
|
|
||||||
// UNLIMITED_MIN_SPEED_VALUE = 30; // Km/h
|
|
||||||
[[maybe_unused]] constexpr static double UNLIMITED_THROTTLE_SPEED_VALUE = 70; // Km/h
|
|
||||||
|
|
||||||
[[maybe_unused]] constexpr static double SPEED_FACTOR = 0.1;
|
|
||||||
[[maybe_unused]] constexpr static double DISTANCE_FACTOR = 0.1;
|
|
||||||
[[maybe_unused]] constexpr static double SENESORGAIN_FACTOR = 0.1;
|
|
||||||
[[maybe_unused]] constexpr static double ASSIST_FACTOR = 1.5625;
|
|
||||||
[[maybe_unused]] constexpr static double VOLTAGE_FACTOR = 0.001;
|
|
||||||
[[maybe_unused]] constexpr static double CURRENT_FACTOR = 0.001;
|
|
||||||
[[maybe_unused]] constexpr static double NORMALIZED_VOLTAGE_OFFSET = 20.8333;
|
|
||||||
[[maybe_unused]] constexpr static double NORMALIZED_VOLTAGE_FAKTOR = 0.416667;
|
|
||||||
|
|
||||||
// misc
|
|
||||||
//#define cbc::Version "CanBusControl 0.0.01 / 02.07.2022"
|
|
||||||
[[maybe_unused]] constexpr static const char* Version = "BionxControl 0.1.00 / 08.11.2022 © 2022 chris@sourceworx.org";
|
|
||||||
|
|
||||||
[[maybe_unused]] constexpr static const char* OrgName = "source::worx";
|
|
||||||
[[maybe_unused]] constexpr static const char* DomainName = "sourceworx.org";
|
|
||||||
[[maybe_unused]] constexpr static const char* AppName = "BionxControl";
|
|
||||||
|
|
||||||
|
|
||||||
// timer
|
|
||||||
void delay_seconds( uint32_t );
|
|
||||||
void delay_millis( uint32_t );
|
|
||||||
void delay_micros( uint32_t );
|
|
||||||
void processEventsFor(int milliseconds);
|
|
||||||
|
|
||||||
QString formatInt( int count, int len );
|
|
||||||
} // namespace bc
|
|
||||||
|
|
||||||
// abbreviations:
|
|
||||||
// SOC = State Of Charge
|
|
||||||
// LMD = Last Measured Discharge
|
|
||||||
// NIP = ?
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Needed ?
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
template <typename E>
|
|
||||||
constexpr auto to_u(E e) noexcept {
|
|
||||||
return static_cast<std::underlying_type_t<E>>(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// constants.h
|
|
||||||
#pragma once
|
|
||||||
#include <QLatin1StringView>
|
|
||||||
|
|
||||||
namespace Consts {
|
|
||||||
using namespace Qt::Literals::StringLiterals;
|
|
||||||
// 1. Compile-Time Konstante (constexpr)
|
|
||||||
// 2. Kein Heap-Speicher (Zero Allocation)
|
|
||||||
// 3. Minimale Binary-Größe (1 Byte char) <- 8 Bit!
|
|
||||||
// Beste Performance, keine Allokation, Typ-Sicher
|
|
||||||
inline constexpr auto OrgName = "source::worx"_L1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct BC
|
|
||||||
{
|
|
||||||
Q_GADGET // Aktiviert das Meta-System für diese Klasse ohne QObject-Overhead
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// __fix! gehört das hier hin ?
|
|
||||||
enum class OpID : uint8_t
|
|
||||||
{
|
|
||||||
ReadValue,
|
|
||||||
WriteValue,
|
|
||||||
};
|
|
||||||
Q_ENUM(OpID)
|
|
||||||
|
|
||||||
enum class OpState : uint8_t
|
|
||||||
{
|
|
||||||
NoOP,
|
|
||||||
Bu,
|
|
||||||
};
|
|
||||||
Q_ENUM(OpState)
|
|
||||||
|
|
||||||
|
|
||||||
enum class ID : uint8_t
|
|
||||||
{
|
|
||||||
//{%Region Console}
|
|
||||||
|
|
||||||
Invalid = 0x0,
|
|
||||||
ID_Pimp = 0xF1, // dummy id to identify the tuning page
|
|
||||||
|
|
||||||
|
|
||||||
ID_Console_Master = 0x08, // (Can Id In Master Mode)
|
|
||||||
ID_Console_Slave = 0x48, // (Can Id In Slave Mode)
|
|
||||||
// ID_Console_Response = 0x58,
|
|
||||||
ID_Bib = 0x58,
|
|
||||||
|
|
||||||
// Reg 0..79 Unused
|
|
||||||
|
|
||||||
Cons_Stat_Dist_Hi = 0x50, // [Factor:0.1]
|
|
||||||
Cons_Stat_Dist_Lo = 0x51,
|
|
||||||
Cons_Stat_Avgspeed_Hi = 0x52, // [Factor:0.1]
|
|
||||||
Cons_Stat_Avgspeed_Lo = 0x53,
|
|
||||||
|
|
||||||
// Reg 84..99 Unused
|
|
||||||
|
|
||||||
Cons_Stat_Odo_Hihi = 0x64, // Odometer [Unit:Km, Faktor:0.1]
|
|
||||||
Cons_Stat_Odo_Hilo = 0x65, // !!! Reverse Byte Order On Writing !!!
|
|
||||||
Cons_Stat_Odomoter_Lohi = 0x66,
|
|
||||||
Cons_Stat_Odo_Lolo = 0x67,
|
|
||||||
|
|
||||||
Cons_Preference_Nip_Hihi = 0x68, // -
|
|
||||||
Cons_Preference_Nip_Hilo = 0x69,
|
|
||||||
Cons_Preference_Nip_Lohi = 0x6a,
|
|
||||||
Cons_Preference_Nip_Lolo = 0x6b,
|
|
||||||
Cons_Throttle_Calibrated = 0x6c, // Throttle Calibration Performed
|
|
||||||
Cons_Stat_Chrono_Second = 0x6d, // Trip Time Seconds
|
|
||||||
Cons_Stat_Chrono_Minute = 0x6e, // Trip Time Minutes
|
|
||||||
Cons_Stat_Chrono_Hour = 0x6f, // Trip Time Hours
|
|
||||||
Cons_Preference_Lcd_Contrast = 0x70, // Lcd Contrast
|
|
||||||
Cons_Sn_Location = 0x71, // Location
|
|
||||||
Cons_Sn_Year = 0x72, // Mfd Year
|
|
||||||
Cons_Sn_Month = 0x73, // Mfd Month
|
|
||||||
Cons_Sn_Day = 0x74, // Mfd Day
|
|
||||||
|
|
||||||
Cons_Sn_Pn_Hi = 0x75, // Product Number
|
|
||||||
Cons_Sn_Pn_Lo = 0x76,
|
|
||||||
Cons_Sn_Item_Hi = 0x77, // Serial Number
|
|
||||||
Cons_Sn_Item_Lo = 0x78,
|
|
||||||
|
|
||||||
// Reg 121 Unused
|
|
||||||
|
|
||||||
Cons_Assist_Gauge_Joint = 0x7a, // Gauge Joint [Range:0..11]
|
|
||||||
Cons_Throttle_Min_Hi = 0x7b, // Throttle Min Actor Value
|
|
||||||
Cons_Throttle_Min_Lo = 0x7c,
|
|
||||||
Cons_Throttle_Max_Hi = 0x7d, // Throttle Max Actor Value
|
|
||||||
Cons_Throttle_Max_Lo = 0x7e,
|
|
||||||
|
|
||||||
// Reg 127 Unused
|
|
||||||
|
|
||||||
Cons_Preference_Light_On_At_Start = 0x80, // Lightonatstart Indicate If The Accessory Shall Be Enabled When Turning The Bike On. 0-No, 1-Yes
|
|
||||||
|
|
||||||
Cons_Geometry_Circ_Hi = 0x81, // Circumference Of The Rear Wheel [Mm]
|
|
||||||
Cons_Geometry_Circ_Lo = 0x82,
|
|
||||||
|
|
||||||
Cons_Assist_Maxspeed_Flag = 0x83, // Indicates That There Is An Upper Speed Limit Where The Motor Is Allowed To Assist
|
|
||||||
Cons_Assist_Maxspeed_Hi = 0x84, // Maximum Speed For Which The Motor Can Assist. This Is Irrelevant If Maxspeedflag Is Not Set [Unit:Km/H, Range:1..??, Factor:0.1] (Code 3773)
|
|
||||||
Cons_Assist_Maxspeed_Lo = 0x85,
|
|
||||||
|
|
||||||
Cons_Throttle_Maxspeed_Flag = 0x86, // Throttle Max Speed Flag
|
|
||||||
Cons_Throttle_Maxspeed_Hi = 0x87, // Throttle Max Speed Msb [Unit:Km/H, Factor:0.1] Code 3775
|
|
||||||
Cons_Throttle_Maxspeed_Lo = 0x88,
|
|
||||||
Cons_Assist_Minspeed_Flag = 0x89, // Min Speed Flag
|
|
||||||
Cons_Assist_Minspeed = 0x8a, // Min Speed Code 3776
|
|
||||||
|
|
||||||
Cons_Assist_Brake_Level = 0x8b, // Brake Rekuperation Level [Unit:%, Range:0..64, Factor:1.5625] Code 2002
|
|
||||||
Cons_Preference_Trip_To_Empty_Flag = 0x8c, // 0:Hide, 1:Show Remaining Time/Dist Pc2003 (No Effect Anymore?)
|
|
||||||
Cons_Preference_Display_Units = 0x8d, // Indicates Unit System To Use When Displaying Units. 0-English, 1-Metric
|
|
||||||
Cons_Throttle_Enable_Onstrain = 0x8e, // Allow Throttle Over Maxspeed If Strain Gauge Signal Detected
|
|
||||||
|
|
||||||
// Reg 143..159 Unused
|
|
||||||
|
|
||||||
Cons_Assist_Brake_Flag = 0xa0, // Brage Sensor Enable, 0: Brake Sensor Off, 1: Sensor On Code 2006
|
|
||||||
Cons_Assist_Brake_Polarity = 0xa1, // Brake Sensor Type: 0: No (Normal Open), 1: Nc (Normal Closed), 2:0-5 (Analog 0..5v), 3:5-0 (Analog 5..0v) Code 2006
|
|
||||||
Cons_Assist_Gauge_Filter = 0xa2, // Torque Sensor Speed [Range:0..8 (1..4 Recommended)] Code 1234
|
|
||||||
|
|
||||||
Cons_Rev_Sw = 0xa3, // Software Version
|
|
||||||
|
|
||||||
Cons_Assist_Gauge_Gain = 0xa4, // Sensor Gain [Range:0.1..4.0, Factor:0.1] Code 0007
|
|
||||||
Cons_Assist_Gain_A = 0xa5, // Torque Sensor Extra Gain [Range:0.1..4.0, Factor:0.1] Code 0008a
|
|
||||||
Cons_Assist_Gain_B = 0xa6, // Torque Sensor Extra Gain Max Speed [Unit:Km/H, Range:0.0..25.0, Factor:0.1] Code 0008b
|
|
||||||
Cons_Sn_Type = 0xa7, // Type Of Console: 0-Eps, 1-Ride+, 2-Boost.
|
|
||||||
Cons_Preference_Region = 0xa8, // Region
|
|
||||||
Cons_Preference_Configbit_0 = 0xa9, // Configbit0
|
|
||||||
Cons_Throttle_Enable_Boost_Display = 0xaa, // Display The "Boost" Message Or Pictogram When It Activates
|
|
||||||
Cons_Assist_Autoregen_Flag = 0xab, // Autoregen Flag
|
|
||||||
|
|
||||||
// Reg 172 Unused // Regenenabled, Yet Unused
|
|
||||||
|
|
||||||
Cons_Rev_Sub = 0xad, // Software Subversion
|
|
||||||
Cons_Preference_Light_Button_Mode = 0xae, // Indicate The Operation Of Console Button "Light/Power". 0-Click Turns Bike Off, Hold Toggles Accessory, 1-Click Toggle Accessory, Hold Turns Bike Off
|
|
||||||
Cons_Preference_Expertmode = 0xaf, // Expertmode Add New Display Mode For Expert Mode (Unitl Hw 15)
|
|
||||||
|
|
||||||
Cons_Assist_Level_1 = 0xb0, // Assist Level 1 [Unit:%, Factor:1,5625]
|
|
||||||
Cons_Assist_Level_2 = 0xb1, // Assist Level 2 [Unit:%, Factor:1,5625]
|
|
||||||
Cons_Assist_Level_3 = 0xb2, // Assist Level 3 [Unit:%, Factor:1,5625]
|
|
||||||
Cons_Assist_Level_4 = 0xb3, // Assist Level 4 [Unit:%, Factor:1,5625]
|
|
||||||
Cons_Assist_Initlevel = 0xb4, // Initial Assist Level [Range:0..4]
|
|
||||||
|
|
||||||
Cons_Preference_Codes_Hihi = 0xb5, // Codes Lsb 0-(3771, 2005)Wheel Circumference, 1-(3772)Diagnostic Mode, 2-(3773)Max Speed, 3-(3774)Overvoltage Protection, 4-(3775)Max Throttle Speed, 5-(3776)Minimum Assist Speed, 6-(1976)Motor Direction, 7-(5000)Deprecated, 8-(2001)Metric Vs Imperial, 9-(2002)Regen Value, 10-(2003)Remaining Distance, 11-(2004)Clock Time, 12-(2006)Brake Switch Config, 13-(2007)Throttle Polarity, 14-(2008)Accessory Voltage, 15-(0041)Slave Console, 16-(1234)Filter, 17-(1970)Light Sensor, 18-(0007)Gauge Gain, 19-(0008)Assistance Gain, 20-(0009)Gauge Joint, 21-(0911)Deprecated, 22-(0001)Console Info, 23-(0002)Battery Info, 24-(0003)Motor Info, 25-(6000)Battery Statistics, 26-(0006)Speed Gain, 27-Alarm, 28-Time
|
|
||||||
Cons_Preference_Codes_Hilo = 0xb6,
|
|
||||||
Cons_Preference_Codes_Lohi = 0xb7,
|
|
||||||
Cons_Preference_Codes_Lolo = 0xb8,
|
|
||||||
Cons_Preference_Codesrw_Hihi = 0xb9, // Codesrw Lsb Same Bit As Console.Preference.Codes Except For: 28-Mountain Mode
|
|
||||||
Cons_Preference_Codesrw_Hilo = 0xba,
|
|
||||||
Cons_Preference_Codesrw_Lohi = 0xbb,
|
|
||||||
Cons_Preference_Codesrw_Lolo = 0xbc,
|
|
||||||
Cons_Sn_Oem_Hi = 0xbd, // Oem
|
|
||||||
Cons_Sn_Oem_Lo = 0xbe,
|
|
||||||
Cons_Preference_Throttle_Mode = 0xbf, // Throttlemode Configure The Throttle For The Menu Change Mode (Until Hw 15)
|
|
||||||
Cons_Assist_Speedgain = 0xc0, // [ Factor:0,1 ]
|
|
||||||
Cons_Sn_Product_Hi = 0xc1, // Product
|
|
||||||
Cons_Sn_Product_Lo = 0xc2,
|
|
||||||
Cons_Throttle_Boost_Triggerlevel = 0xc3, // Boost Trigger Level [Unit:%, Range:1.5..50, Factor:1.5625] Code 3779
|
|
||||||
Cons_Preference_Flip_Side = 0xc4, // Indicates On What Side Of The Handlebar Is Located The Console. 0-Right, 1-Left Code 2009
|
|
||||||
Cons_Config_Testmode = 0xc5, // Writing A 1 To This Register Allows Setting The Console In Test Mode To Test The Lcd And Buttons
|
|
||||||
Cons_Config_Testmode_Hw14 = 0xc3, // Reg C3 With Hw14
|
|
||||||
|
|
||||||
Cons_Assist_Mountain_Cap = 0xc6, // Maximum Set Point To Send To Motor When In Mountain Mode. 0-Disabled [Unit:%, Range:0..100, Faktor:1.5625]
|
|
||||||
Cons_Config_Last_Mode = 0xc7, // Writing 255 Will Disable The Last Mode On Display Power On, 0 Will Enable The Last Mode On Display Power On
|
|
||||||
|
|
||||||
Console_Config_Last_Mode_On = 0x00,
|
|
||||||
Console_Config_Last_Mode_Off = 0xff,
|
|
||||||
|
|
||||||
// Reg 200..207 Unused
|
|
||||||
|
|
||||||
Cons_Rev_Hw = 0xd0, // Hardware Version
|
|
||||||
Cons_Status_Slave = 0xd1, // Writing A 1 To This Register Allows Going Imemdiatly In Slave Mode, Cannot Be Set To 0
|
|
||||||
|
|
||||||
Cons_Throttle_Raw_Hi = 0xd2, // Throttle Raw Position
|
|
||||||
Cons_Throttle_Raw_Lo = 0xd3,
|
|
||||||
Cons_Throttle_Position = 0xd4, // Throttle Position [Factor:1.5625]
|
|
||||||
|
|
||||||
// Reg 213 Unused // Outdated, Formerly Used By Pref. Language
|
|
||||||
// Reg 214 Unused // And Boat Related. Now No Data From Regs.
|
|
||||||
|
|
||||||
Cons_Assist_Level_Rekuperation_3 = 0xd7, // 215 Reku Level 3 [Unit:%, Factor:1,5625]
|
|
||||||
Cons_Assist_Level_Rekuperation_4 = 0xd8, // 216 Reku Level 4 [Unit:%, Factor:1,5625]
|
|
||||||
Cons_Config_Service_Timestamp_Hi = 0xd9, // Day, In Battery-Relative Value, From Which Console Displays "Service". 0 To Disable The Feature
|
|
||||||
Cons_Config_Service_Zimestamp_Lo = 0xda,
|
|
||||||
Cons_Config_Service_Distance_Hi = 0xdb, // Odometer Value, From Which Console Displays "Service". 0 To Disable The Feature
|
|
||||||
Cons_Config_Service_Distance_Lo = 0xdc,
|
|
||||||
|
|
||||||
// Reg 211 Unused
|
|
||||||
|
|
||||||
Cons_Assist_Level_Rekuperation_1 = 0xde, // Reku Level 1 [Unit:%, Factor:1,5625]
|
|
||||||
Cons_Assist_Level_Rekuperation_2 = 0xdf, // Reku Level 2 [Unit:%, Factor:1,5625]
|
|
||||||
|
|
||||||
// Reg 224..255 Unused
|
|
||||||
|
|
||||||
//{%Endregion Console}
|
|
||||||
|
|
||||||
//{%Region Battery}
|
|
||||||
ID_Battery = 0x10,
|
|
||||||
|
|
||||||
// ID_Battery_Response = 0x08,
|
|
||||||
Reg_Battery_Config_Allow_Buckcharging_On_Bike = 0x12, // Specifies If The Battery Can Recharge In Buck Mode Even On A Bike. Make Sure It Is Impossible To Have An Accessory Output Before Setting This To 1. 0: Disallow, 1: Allow
|
|
||||||
Reg_Battery_Status_Charger_Manager_Status = 0x13, // Gives State Of Charging Mef: 0-Off, 1-Stand-By, 2-Charger, 3-Accessory, 4-Vdcin Sense, 5-Overtemp, 6-Charge Done, 7-Buck Failed
|
|
||||||
Reg_Battery_Config_Wake_On_Powervoltage = 0x14, // Specifies If The Battery Should Wake Up Automatically When A Voltage Is Present On The Vpower. A Value Of 0 Disables The Feature
|
|
||||||
|
|
||||||
Reg_Battery_Config_Sla_Constant_A = 0x15, // ++++ Boat Related (Soc Estimator)
|
|
||||||
Reg_Battery_Config_Sla_Constant_B = 0x16, // ++++ Boat Related (Soc Estimator)
|
|
||||||
Reg_Battery_Config_Sla_Constant_C = 0x15, // ++++ Boat Related (Soc Estimator)
|
|
||||||
|
|
||||||
Reg_Battery_Rev_Sub = 0x18, // Software Subversion
|
|
||||||
|
|
||||||
Reg_Battery_Config_Sla_Constant_D = 0x15, // ++++ Boat Related (Soc Estimator)
|
|
||||||
|
|
||||||
Reg_Battery_Rtc_Last_Valid_Timestamp_Hihi = 0x19, // Indicates Last Valid Battery Time. This Read-Only Register Is Set To Rtc.Time When Written And Then Refresh Each 34 Minutes
|
|
||||||
Reg_Battery_Rtc_Last_Valid_Timestamp_Hilo = 0x1a,
|
|
||||||
Reg_Battery_Rtc_Last_Valid_Timestamp_Lohi = 0x1b,
|
|
||||||
Reg_Battery_Rtc_Last_Valid_Timestamp_Lolo = 0x1c,
|
|
||||||
|
|
||||||
Reg_Battery_Status_Flags_Hi = 0x1d, // Alert Status Bits: 0-Vctrl (Code 20), 1-Precharge (Code 21 And 67), 2-Relay (Code 22), 3-Bms (Code 23), 4-Dcdc (Code 28), 6-Gg Out Of Range Temperature, 7-Battery Pack Out Of Range Temperature, 8-Balancer Overvolt (Code 62), 9-Balancer Undervolt (Code 61), 10-Pack Problem (Code 63), 11-Accessory Overcurrent (Code 60), 12-Electronic Fuse (Code 66), 13-Balancer Plug Not Connected, 14- +5v Short(Lached)
|
|
||||||
|
|
||||||
Reg_Battery_Status_Cellpack_Current_Hi = 0x1e, // Reading Battery Current By A Shunt Resistor. No Delay, No Calibration Compared To Battery.Gg.Ai [Unit:A, Factor:0.001]
|
|
||||||
Reg_Battery_Status_Cellpack_Current_Lo = 0x1f, // !!! Signed !!!
|
|
||||||
|
|
||||||
Reg_Battery_Config_Power_Voltage_Enable = 0x21, // - ??? Enable/Disable Vpower ???
|
|
||||||
|
|
||||||
Reg_Battery_Config_Accessory_Enabled = 0x22, // -
|
|
||||||
|
|
||||||
Reg_Battery_Config_Shutdown = 0x25, // Write 1 To Shutdwon System
|
|
||||||
|
|
||||||
Reg_Battery_Config_Control_Voltage_Enable = 0x26, // Enable/Disable Vcontrol
|
|
||||||
|
|
||||||
Reg_Battery_Config_Accessory_Voltage = 0x28, // - Until Hw 52 [Unit:V, Factor:6]
|
|
||||||
// Since Hw 60 [Unit:V, Factor:0.1]
|
|
||||||
|
|
||||||
Reg_Battery_Config_Cap_Sense_Mode = 0x29, // Controls The Mode Of Operation Of The Soc Level Indicator. 0: Inactive, 1: Touch Detect When The Battery Is Off, 2: Touch Detect When Off And Soc Indication When Battery Is On. 3: Red And Blue Colors . 4: 5levels Soc
|
|
||||||
|
|
||||||
Reg_Battery_Config_Communication_Mode = 0x2a, // Determines How The Battery Communicates. To Change The Value, We Must First Write 0xaa To This Register And Then Write 1 To Switch To I2c Or 2 To Switch To Can
|
|
||||||
Battery_Config_Communication_Mode_Key = 0xaa,
|
|
||||||
|
|
||||||
Reg_Battery_Status_Estimated_Soc = 0x30, // Return An Estimated Value Of Soc Based On Battery Voltage. Only Works With Liion Battery [Unit:%]
|
|
||||||
|
|
||||||
Reg_Battery_Status_Battery_Voltage_Normalized = 0x32, // Battery Voltage Normalized With 3.7v/Cell. Status.Vbattinternal It Used In Rev 104 And Less Otherwise Status.Vbatt [Unit:V, Factor:0.416667, Offset:20.8333]
|
|
||||||
Reg_Battery_Stat_Battery_Avgvoltage_Normalized = 0x33, // Average Battery Voltage Read During 50s Based On Battery.Status.Vbatt, In Percentage Of Its Nominal Voltage [Unit:V, Factor:0.416667, Offset:20.8333]
|
|
||||||
|
|
||||||
Reg_Battery_Config_Shipmode = 0x37, // Determines If The Battery Is To Go In Ship Mode (Only External Power Can Wake It) Upon Its Next Shutdown. We Need To First Write 0xaa And Then The Desired Value To Set The Value. 0-Normal Mode, 1-Ship Mode
|
|
||||||
Battery_Config_Shipmode_Key = 0xaa,
|
|
||||||
|
|
||||||
Reg_Battery_Rev_Hw = 0x3b, // Hardware Version
|
|
||||||
Reg_Battery_Rev_Sw = 0x3c, // Software Version
|
|
||||||
|
|
||||||
Reg_Battery_Config_Type = 0x3d, // -
|
|
||||||
|
|
||||||
Reg_Battery_Rev_Bom = 0x41, // Identification Of Printed Circuit Board Bill Of Material Version. 1: All Smc6.2 And Smc#6.3r1. 8: Smc#6.3r4
|
|
||||||
|
|
||||||
Reg_Battery_Config_Taillamp_Intensity = 0x43, // Controls The Intensity Of The Tail Lamp. 0: Off. 1-100%: On
|
|
||||||
Reg_Battery_Config_Accessory_Mounted = 0x44, // -
|
|
||||||
Reg_Battery_Config_Battint_Voltage_Enable = 0x45, // Enable/Disable Vbattint
|
|
||||||
Reg_Battery_Config_Diag = 0x46, // -
|
|
||||||
Reg_Battery_Config_Force_Done = 0x47, // ++++ Setting This Register To 0x45 Will Force Soc To 100%
|
|
||||||
Battery_Config_Force_Done = 0x45,
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Resets_Hi = 0x48, // Reset Counter
|
|
||||||
Reg_Battery_Stat_Resets_Lo = 0x49,
|
|
||||||
|
|
||||||
Reg_Battery_Status_Internal_Battery_Voltage_Hi = 0x4a, // Reading Of Vbattinternal [Unit:V, Factor:0.001]
|
|
||||||
Reg_Battery_Status_Internal_Battery_Voltage_Lo = 0x4b,
|
|
||||||
|
|
||||||
Reg_Battery_Status_Console_Voltage_Hi = 0x4c, // Reading Of Vconsole (Voltage Applied To Console) [Unit:V, Factor:0.001]
|
|
||||||
Reg_Battery_Status_Console_Voltage_Lo = 0x4d,
|
|
||||||
|
|
||||||
Reg_Battery_Status_12v_Voltage_Hi = 0x4e, // Reading Of Internal 12v [Unit:V, Factor:0.001]
|
|
||||||
Reg_Battery_Status_12v_Voltage_Lo = 0x4f,
|
|
||||||
|
|
||||||
Reg_Battery_Config_Nominal_Battery_Voltage = 0x50, // Battery System Nominal Voltage
|
|
||||||
|
|
||||||
Reg_Battery_Timer_Power_Hi = 0x51, // Time Before The Power Output Shuts Down [Unit:S]
|
|
||||||
Reg_Battery_Timer_Power_Lo = 0x52,
|
|
||||||
Reg_Battery_Timer_Accessory_Hi = 0x53, // Time Before The Accessory Voltage Shuts Down [Unit:S]
|
|
||||||
Reg_Battery_Timer_Accessory_Lo = 0x54,
|
|
||||||
Reg_Battery_Timer_Precharge = 0x55, // Time Allowed To Precharge The Motor, Before Enabling Full Power [Unit:S]
|
|
||||||
Reg_Battery_Timer_Shutdown_Hi = 0x56, // Time Of Inactivity Before The System Shuts Down [Unit:S]
|
|
||||||
Reg_Battery_Timer_Shutdown_Lo = 0x57,
|
|
||||||
|
|
||||||
Reg_Battery_Sn_Location = 0x5b, // Location
|
|
||||||
|
|
||||||
Reg_Battery_Status_Accessory_Voltage_Hi = 0x5e, // Reading Of Vaccessory [Unit:V, Factor:0.001]
|
|
||||||
Reg_Battery_Status_Accessory_Voltage_Lo = 0x5f,
|
|
||||||
|
|
||||||
Reg_Battery_Status_Charge_Level = 0x61, // Batterylevel [Unit:%, Factor:6.6667]
|
|
||||||
Reg_Battery_Cellmon_Balancer_Enabled = 0x65, //
|
|
||||||
|
|
||||||
Reg_Battery_Status_Temperature_Sensor_1 = 0x66, // [Unit:C]
|
|
||||||
Reg_Battery_Status_Temperature_Sensor_2 = 0x67, // !!! Signed !!!
|
|
||||||
Reg_Battery_Status_Temperature_Sensor_3 = 0x68,
|
|
||||||
Reg_Battery_Status_Temperature_Sensor_4 = 0x69,
|
|
||||||
|
|
||||||
Reg_Battery_Sn_Cellpack_Hi = 0x6a, // Serial Number Cellpack
|
|
||||||
Reg_Battery_Sn_Cellpack_Lo = 0x6b,
|
|
||||||
|
|
||||||
Reg_Battery_Cellmon_Channel_Address = 0x6c, // Gateway To Cell Monitor, Write Address Here
|
|
||||||
Reg_Battery_Cellmon_Channeldata_Hi = 0x6d, // And Read 16 Bit Voltages Here
|
|
||||||
Reg_Battery_Cellmon_Channeldata_Lo = 0x6e, // And Here
|
|
||||||
|
|
||||||
Reg_Battery_Cellmon_Calibration_Data_Lo = 0x6f, // Cell Calibration Data, Select Cell Via Reg_Battery_Cellmon_Channel Register
|
|
||||||
// Since Hw 60, Sw 103 16 Bit Values Are Provided, See Reg_Battery_Calibration_Data_Hi Below
|
|
||||||
Reg_Battery_Protect_Unlock = 0x71,
|
|
||||||
Battery_Protect_Lock_Key = 0x00,
|
|
||||||
Battery_Protect_Unlock_Key = 0xaa,
|
|
||||||
|
|
||||||
Reg_Battery_Sn_Year = 0x72, // Mfd. Year
|
|
||||||
Reg_Battery_Sn_Month = 0x73, // Mfd. Month
|
|
||||||
Reg_Battery_Sn_Day = 0x74, // Mfd Day
|
|
||||||
|
|
||||||
Reg_Battery_Sn_Pn_Hi = 0x75, // Part Number
|
|
||||||
Reg_Battery_Sn_Pn_Lo = 0x76,
|
|
||||||
Reg_Battery_Sn_Item_Hi = 0x77, // Serial Number
|
|
||||||
Reg_Battery_Sn_Item_Lo = 0x78,
|
|
||||||
|
|
||||||
Reg_Battery_Cellmon_Calibration_Data_Hi = 0x7c, // Refer Reg_Battery_Calibration_Data_Lo Above
|
|
||||||
|
|
||||||
Reg_Battery_Status_Poweron_Reset_Count = 0x7d, // Return How Many Time Main Microcontroller Hardly Reset
|
|
||||||
|
|
||||||
Reg_Battery_Config_Autoswitch_Communication = 0x7e, // ++++ Allow To Switch Communication Mode Without Shutdown. Write 0xaa, Then 0x01. Comm. Mode Switches. Communicate With Desired Comm. Mode Before 5s (100ms Min) To Validate. Write 0 To Desactivate
|
|
||||||
Battery_Config_Autoswitch_Communication_Key = 0xaa,
|
|
||||||
|
|
||||||
Reg_Battery_Brigde_Charger_Addr = 0x85, // Gateway To Charger, Write Address Here (Needs Unlocking)
|
|
||||||
Reg_Battery_Brigde_Charger_Data = 0x86, // And Read Data Here
|
|
||||||
|
|
||||||
Reg_Battery_Status_Leds = 0x87, // -
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Chargetime_Mean_Hi = 0x8a, // -
|
|
||||||
Reg_Battery_Stat_Chargetime_Mean_Lo = 0x8b, // -
|
|
||||||
Reg_Battery_Stat_Chargetime_Worst_Hi = 0x8c, // -
|
|
||||||
Reg_Battery_Stat_Chargetime_Worst_Lo = 0x8d, // -
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Battery_Cycles_Hi = 0x8e, // - Battery Charge Cycles
|
|
||||||
Reg_Battery_Stat_Battery_Cycles_Lo = 0x8f, // -
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Rtc_Resync = 0x90, // -
|
|
||||||
Reg_Battery_Stat_Lmd_Adapt = 0x91, // -
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Battery_Full_Cycles_Hi = 0x92, // - Battery Full Charge Cycles
|
|
||||||
Reg_Battery_Stat_Battery_Full_Cycles_Lo = 0x93, // -
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Power_Cycles_Hi = 0x96, // Power On Cycles
|
|
||||||
Reg_Battery_Stat_Power_Cycles_Lo = 0x97, // -
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Battery_Max_Voltage = 0x98, // Maximum Voltage Ever Seen By The Battery, In Percentage Of Its Nominal Voltage [Unit:%, Factor:0.416667, Offset:20.8333]
|
|
||||||
Reg_Battery_Stat_Battery_Min_Voltage = 0x99, // Minimum Voltage Ever Seen By The Battery, In Percentage Of Its Nominal Voltage [Unit:%, Factor:0.416667, Offset:20.8333]
|
|
||||||
|
|
||||||
Reg_Battery_Status_Dcin_Voltage_Hi = 0x9a, // Reading Of External Power Supply Voltage [Unit:V, Factor:0.001]
|
|
||||||
Reg_Battery_Status_Dcin_Voltage_Lo = 0x9b,
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Temperature_Max = 0x9c, // - !!! Signed !!!
|
|
||||||
Reg_Battery_Stat_Temperature_Min = 0x9d, // - !!! Signed !!!
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Control_Voltage_Shorts = 0x9e, // Until Hw 52, Now Via I2c Bridge
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Watchdog_Reset_Count = 0x9f, // Return How Many Time Watchdog Reset Trigged
|
|
||||||
Reg_Battery_Status_Reset_Wdt = 0x9f, // - Same As Above?
|
|
||||||
|
|
||||||
Reg_Battery_Rtc_Ctrl = 0xa0, // -
|
|
||||||
|
|
||||||
Reg_Battery_Rtc_Time_Hihi = 0xa1, // Indicates Current Battery Time In Seconds. Its Value Is Normally Relative To Assembly Time
|
|
||||||
Reg_Battery_Rtc_Time_Hilo = 0xa2,
|
|
||||||
Reg_Battery_Rtc_Time_Lohi = 0xa3,
|
|
||||||
Reg_Battery_Rtc_Time_Lolo = 0xa4,
|
|
||||||
|
|
||||||
Reg_Battery_Rtc_Status = 0xa5, // Describes The Status Of The Rtc: 0-In Sync, 1-Write Ok, 2-Read Ok, 3-Update Time, 4-Update Ctrl, 5-Osc Ok, 7-Rtc Detected
|
|
||||||
|
|
||||||
Reg_Battery_Status_Battery_Voltage_Hi = 0xa6, // Reading Of Vbatt. Return Same Value As Vcell13 [Unit:V, Factor:0.001]
|
|
||||||
Reg_Battery_Status_Battery_Voltage_Lo = 0xa7,
|
|
||||||
|
|
||||||
Reg_Battery_Status_Power_Voltage_Hi = 0xaa, // Reading Of Vpower ("High" Voltage Applied To Motor) [Unit:V, Factor:0.001]
|
|
||||||
Reg_Battery_Status_Power_Voltage_Lo = 0xab,
|
|
||||||
|
|
||||||
Reg_Battery_Status_Control_Voltage_Hi = 0xac, // Reading Of Vcontrol (Control Voltage Applied To Motor) [Unit:V, Factor:0.001]
|
|
||||||
Reg_Battery_Status_Control_Voltage_Lo = 0xad,
|
|
||||||
|
|
||||||
Reg_Battery_Config_Pack_Serial = 0xae, // No Of Cells In Serial
|
|
||||||
Reg_Battery_Config_Pack_Parallel = 0xaf, // No Of Cells In Parallel
|
|
||||||
|
|
||||||
Reg_Battery_Gasgage_Dmfsd = 0xb5, // Digital Magnitude Filter And Self Discharge Rate
|
|
||||||
|
|
||||||
Reg_Battery_Config_Ilmd = 0xb9, // - [Unit:Ah, Factor:0.54835]
|
|
||||||
|
|
||||||
Reg_Battery_Gasgage_Soc = 0xbc, // - [Unit:%]
|
|
||||||
|
|
||||||
Reg_Battery_Gasgage_Ai_Hi = 0xd3, // - [Unit:A, Factor:0.002141]
|
|
||||||
Reg_Battery_Gasgage_Ai_Lo = 0xd4,
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Lmd_Hi = 0xd5, // - [Unit:Ah, Factor:0.002142]
|
|
||||||
Reg_Battery_Stat_Lmd_Lo = 0xd6,
|
|
||||||
Reg_Battery_Gasgage_Lmd_Hi = 0xd5, // - [Unit:Ah, Factor:0.002142]
|
|
||||||
Reg_Battery_Gasgage_Lmd_Lo = 0xd6,
|
|
||||||
|
|
||||||
Reg_Battery_Config_Nac_Raddr_Hi = 0xdb, // -
|
|
||||||
Reg_Battery_Config_Nac_Raddr_Lo = 0xdc,
|
|
||||||
|
|
||||||
Reg_Battery_Gasgage_Status_Flags = 0xde, // -
|
|
||||||
|
|
||||||
Reg_Battery_Gasgage_Voltage_Hi = 0xdf, // - [Unit:V, Factor:0.008]
|
|
||||||
Reg_Battery_Gasgage_Voltage_Lo = 0xe0,
|
|
||||||
|
|
||||||
Reg_Battery_Gasgage_Temperatur_Hi = 0xe1, // - [Unit:C, Factor:0.25, Offset:-273]
|
|
||||||
Reg_Battery_Gasgage_Temperatur_Lo = 0xe2,
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Ggjr_Calib = 0xec, // -
|
|
||||||
|
|
||||||
Reg_Battery_Gasgage_Voltage_Divider = 0xed, // Gas Gage External Divider Value. Indicates How The Voltage Is Divided Before Reaching The Gg. For Example, If The Battery Voltage Is 30v And This Register Is 10, The Gg Will Have 3v At Its Input [Factor:0.1]
|
|
||||||
|
|
||||||
Reg_Battery_Config_Nac_Hi = 0xe5, // -
|
|
||||||
Reg_Battery_Config_Nac_Lo = 0xe6,
|
|
||||||
|
|
||||||
Reg_Battery_Protect_Mode = 0xe7, // -
|
|
||||||
Reg_Battery_Protect_Control = 0xe8, // -
|
|
||||||
|
|
||||||
Reg_Battery_Status_Flags_Lo = 0xf0, // Alert Status Bits: 0-Vctrl (Code 20), 1-Precharge (Code 21 And 67), 2-Relay (Code 22), 3-Bms (Code 23), 4-Dcdc (Code 28), 6-Gg Out Of Range Temperature, 7-Battery Pack Out Of Range Temperature, 8-Balancer Overvolt (Code 62), 9-Balancer Undervolt (Code 61), 10-Pack Problem (Code 63), 11-Accessory Overcurrent (Code 60), 12-Electronic Fuse (Code 66), 13-Balancer Plug Not Connected, 14- +5v Short(Lached)
|
|
||||||
|
|
||||||
Reg_Battery_Rtc_Last_Charge_Timestamp_Hihi = 0xf2, // Written On Boot-Up And Shutdown, This Register Indicates When Last Minimum 10% Charge Was Completed
|
|
||||||
Reg_Battery_Rtc_Last_Charge_Timestamp_Hilo = 0xf3,
|
|
||||||
Reg_Battery_Rtc_Last_Charge_Timestamp_Lohi = 0xf4,
|
|
||||||
Reg_Battery_Rtc_Last_Charge_Timestamp_Lolo = 0xf5,
|
|
||||||
|
|
||||||
Reg_Battery_Stat_Charge_Times_Channel = 0xf6, // Indicates Which Charge Statistic Should Be Accessed When Accessing Chargedata. Value Can Be Any Value Between 1 And 9, 1 Being For 10% Stat And 9 For 90% Stat
|
|
||||||
Reg_Battery_Stat_Charge_Times_Data_Hi = 0xf7,
|
|
||||||
Reg_Battery_Stat_Charge_Times_Data_Lo = 0xf8,
|
|
||||||
|
|
||||||
Reg_Battery_Config_Max_Charge_Hi = 0xf9, // Maximum Regen. Current On Vpower [Unit:A, Factor:0.001]
|
|
||||||
Reg_Battery_Config_Max_Charge_Lo = 0xfa,
|
|
||||||
|
|
||||||
Reg_Battery_Config_Max_Discharge_Hi = 0xfb, // Maximum Drawn Current On Vpower [Unit:A, Factor:0.001]
|
|
||||||
Reg_Battery_Config_Max_Discharge_Lo = 0xfc,
|
|
||||||
|
|
||||||
Reg_Battery_Config_Cellcapacity_Hi = 0xfd, // - [Unit:Ah, Factor:0.001]
|
|
||||||
Reg_Battery_Config_Cellcapacity_Lo = 0xfe,
|
|
||||||
|
|
||||||
|
|
||||||
Reg_Battery_Bridge_I2c_Regaddr_Device = 0x58, // Gateway To I2c Registers, Write Device (Highbyte) Here,
|
|
||||||
Reg_Battery_Bridge_I2c_Regaddr_Register = 0x70, // Register (Lowbyte) Here
|
|
||||||
Reg_Battery_Bridge_I2c_Register_Data = 0x60, // And Read Data Here
|
|
||||||
|
|
||||||
|
|
||||||
// Battery Cell Monitor Registers
|
|
||||||
Reg_Cellmon_Channel_Voltage_1 = 0x01, // [Unit:V, Factor:0.001]
|
|
||||||
// ...
|
|
||||||
Reg_Cellmon_Channel_Voltage_13 = 0x0d, // [Unit:V, Factor:0.001]
|
|
||||||
|
|
||||||
Reg_Cellmon_Cell_Voltage_1 = 0x81, // [Unit:V, Factor:0.001]
|
|
||||||
// ... // !!! Signed !!!
|
|
||||||
Reg_Cellmon_Cell_Voltage_13 = 0x8d, // [Unit:V, Factor:0.001]
|
|
||||||
|
|
||||||
Reg_Cellmon_Status_Bomid_Voltage = 0xc8, // Raw Voltage Of The Resistor Divider Used To Identify The Revision Of The Bom
|
|
||||||
Reg_Cellmon_Status_Packid_Voltage = 0xc9, // Raw Voltage Of The Resistor Divider Used To Identify The Cell Pack
|
|
||||||
Reg_Cellmon_Status_3v3_Voltage = 0xca, // Internal Voltage Of The 3.3v Derived From The Internal 5v [Unit:V, Factor:0.001]
|
|
||||||
Reg_Cellmon_Status_5v_Voltage = 0xcb, // Internal Voltage Of The 5(5.5)V Derived From The Internal 12v [Unit:V, Factor:0.001]
|
|
||||||
|
|
||||||
Reg_Cellmon_Calibration_1 = 0x01, // [Unit:%, Factor:0.03] !!! Signed !!!
|
|
||||||
// ... // !!! Signed !!!
|
|
||||||
Reg_Cellmon_Calibration_13 = 0x0d, // [Unit:%, Factor:0.03]
|
|
||||||
|
|
||||||
Reg_Charger_Status_Flags_Hi = 0x02, // -
|
|
||||||
Reg_Charger_Status_Flags_Lo = 0x03, // -
|
|
||||||
|
|
||||||
Reg_Charger_Mode = 0x10, // Indicates The Mode Of The On-Board Charger. 0-Low Power, 1-Idle, 2-Charging, 3-Accessory Output, 5-Calibration, 99-Fault
|
|
||||||
|
|
||||||
Reg_Charger_Final_Voltage_Hi = 0x12, // Set Final Charge Voltage [Unit:V, Factor:0.01]
|
|
||||||
Reg_Charger_Final_Voltage_Lo = 0x13,
|
|
||||||
|
|
||||||
Reg_Charger_Current_Hi = 0x14, // Set Charge Current [Unit:A, Factor:0.001]
|
|
||||||
Reg_Charger_Current_Lo = 0x15,
|
|
||||||
|
|
||||||
Reg_Charger_Voltage_Calibration_Hi = 0x42, // Multiplier Applied On Charger Voltage Reading For Its Calibration
|
|
||||||
Reg_Charger_Voltage_Calibration_Lo = 0x43,
|
|
||||||
|
|
||||||
Reg_Charger_Current_Calibration_Hi = 0x46, // Multiplier Applied On Charger Current Reading For Its Calibration
|
|
||||||
Reg_Charger_Current_Calibration_Lo = 0x47,
|
|
||||||
|
|
||||||
Reg_Charger_Rev_Charger = 0x56, // -
|
|
||||||
|
|
||||||
//{%Endregion}
|
|
||||||
|
|
||||||
// {%Region Motor}
|
|
||||||
ID_Motor = 0x20,
|
|
||||||
// ID_Motor_Response = 0x08,
|
|
||||||
Motor_Assist_Level = 0x09, // [Unit:%, Range:-100..100, Factor:1.5625] !!! Signed !!!
|
|
||||||
|
|
||||||
Motor_Assist_Walk_Level = 0x0a, // Top Level When Assisting In Walk Mode [Unit:%, Factor:1.5625]
|
|
||||||
Motor_Assist_Walk_Speed_Decrease_Start = 0x0b, // Speed From Which The Motor Starts Diminishing Its Assistance When Using The "Walk Mode" [Unit:Km/H, Factor:0.1]
|
|
||||||
Motor_Assist_Walk_Speed_Decrease_End = 0x0c, // Speed At Which The Motor Gives No More Assistance When Using The "Walk Mode" [Unit:Km/H, Factor:0.1]
|
|
||||||
Motor_Assist_Walk_Level_Max = 0x0d, // Top Level When Assisting In Walk Mode [Unit:%, Factor:1.5625]
|
|
||||||
|
|
||||||
Motor_Status_Speed = 0x11, // - [Unit:Rpm, Factor:9.091]
|
|
||||||
Motor_Status_Power_Meter = 0x14, // - [Unit:%, Factor:1.5625]
|
|
||||||
|
|
||||||
Motor_Status_Temperature = 0x16, // - [Unit:C]
|
|
||||||
|
|
||||||
Motor_Rev_Hw = 0x19, // Hardware Version
|
|
||||||
Motor_Rev_Sw = 0x20, // Software Version
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Value = 0x21, // - [Unit:%, Range:0?..100, Factor:1.5625]
|
|
||||||
|
|
||||||
Motor_Rev_Sub = 0x22, // Software Subversion
|
|
||||||
|
|
||||||
Motor_Config_Communication_Mode_Lo = 0x36, // - 8 Bit Until Sw 83
|
|
||||||
|
|
||||||
Motor_Assist_Lowspeed_Ramp_Flag = 0x40, // Enables A Lower Speed Ramp. 0: Ramp Disabled, 1: Ramp Enabled
|
|
||||||
|
|
||||||
Motor_Assist_Direction = 0x42, // -
|
|
||||||
Motor_Sn_Stator_Type = 0x43, // -
|
|
||||||
Motor_Geometry_Circ_Hi = 0x44,
|
|
||||||
Motor_Geometry_Circ_Lo = 0x45,
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Polarity = 0x46, // -
|
|
||||||
|
|
||||||
Motor_Status_Main = 0x47, // Indicates The Current Main Status Of The Motor. 0-Running, 1-Nocommand, 2-Startup, 3-I2cshutoff, 4-Antibackwardshort, 5-Alarmregen, 6-Alarmshort, 7-Overspeedi, 8-Overspeedv, 9-V12uvp, 10-V12ovp, 11-Vpwruvp, 12-Vpwrovp, 13-Ocprotect, 14-Badstatorpn, 15-Hallerror
|
|
||||||
|
|
||||||
Motor_Sn_Item_Hi = 0x60, // Serial Number
|
|
||||||
Motor_Sn_Item_Lo = 0x61,
|
|
||||||
Motor_Sn_Pn_Hi = 0x62, // Partnumber
|
|
||||||
Motor_Sn_Pn_Lo = 0x63,
|
|
||||||
Motor_Sn_Year = 0x64, // Mfd. Year
|
|
||||||
Motor_Sn_Month = 0x65, // Mfd. Month
|
|
||||||
Motor_Sn_Day = 0x66, // Mfd. Day
|
|
||||||
|
|
||||||
Motor_Sn_Oem_Hi = 0x67, // Oem
|
|
||||||
Motor_Sn_Oem_Lo = 0x68,
|
|
||||||
Motor_Sn_Product_Hi = 0x69, // Product
|
|
||||||
Motor_Sn_Product_Lo = 0x6a,
|
|
||||||
Motor_Sn_Location = 0x6b, // Location
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Type = 0x6c, // -
|
|
||||||
|
|
||||||
Motor_Assist_Stator_Pn_Hi = 0x6d, // -
|
|
||||||
Motor_Assist_Stator_Pn_Lo = 0x6e, //
|
|
||||||
|
|
||||||
Motor_Status_Power_Voltage_Hi = 0x70, // - [Unit:V, Factor:0.001]
|
|
||||||
Motor_Status_Power_Voltage_Lo = 0x71,
|
|
||||||
|
|
||||||
Motor_Status_12v_Voltage_Hi = 0x72, // - [Unit:V, Factor:0.001]
|
|
||||||
Motor_Status_12v_Voltage_Lo = 0x73,
|
|
||||||
|
|
||||||
Motor_Status_5v_Voltage_Hi = 0x74, // - [Unit:V, Factor:0.001]
|
|
||||||
Motor_Status_5v_Voltage_Lo = 0x75,
|
|
||||||
|
|
||||||
Motor_Stat_Max_Power_Voltage_Hi = 0x80, // - [Unit:V, Factor:0.001]
|
|
||||||
Motor_Stat_Max_Power_Voltage_Lo = 0x81,
|
|
||||||
|
|
||||||
Motor_Stat_Max_Temperature_Hi = 0x82, // -
|
|
||||||
Motor_Stat_Max_Temperature_Lo = 0x83,
|
|
||||||
|
|
||||||
Motor_Stat_Odo_Hi = 0x84, // - [Unit:Km]
|
|
||||||
Motor_Stat_Odo_Lo = 0x85,
|
|
||||||
|
|
||||||
Motor_Stat_Chrono_Hours_Hi = 0x86, // - [Unit:H]
|
|
||||||
Motor_Stat_Chrono_Hours_Lo = 0x87,
|
|
||||||
|
|
||||||
Motor_Stat_Chrono_Seconds_Hi = 0x88, // - [Unit:S]
|
|
||||||
Motor_Stat_Chrono_Seconds_Lo = 0x89,
|
|
||||||
|
|
||||||
Motor_Preference_Region = 0x8a, // -
|
|
||||||
|
|
||||||
Motor_Assist_Maxspeed = 0x8b, // - [Unit:Km/H]
|
|
||||||
Motor_Assist_Dynamic_Flag = 0x8c, // - [Range:0..1]
|
|
||||||
|
|
||||||
Motor_Config_Pwm_Limit_Enable = 0x8d, // -
|
|
||||||
|
|
||||||
Motor_Status_Codes = 0x92, // Indicates Conditions Currently Detected By Motor. Bit 0-Sensor Saturation
|
|
||||||
Motor_Status_Codes_Latch = 0x93, // Indicates Conditions Detected By Motor Since Its Last Power Up. See Bit Description Of Status.Codes
|
|
||||||
|
|
||||||
|
|
||||||
Motor_Protect_Unlock = 0xa5, // Unlock Register, Write Unlock_Key Here Before Setting Protected Registers
|
|
||||||
Motor_Protect_Unlock_Key = 0xaa,
|
|
||||||
Motor_Protect_Lock_Key = 0x00,
|
|
||||||
|
|
||||||
Motor_Stat_Hall_Dchs_Hi = 0xb0, // -
|
|
||||||
Motor_Stat_Hall_Dchs_Lo = 0xb1,
|
|
||||||
|
|
||||||
Motor_Stat_Hall_Trans_Hi = 0xb2, // -
|
|
||||||
Motor_Stat_Hall_Trans_Lo = 0xb3,
|
|
||||||
|
|
||||||
Motor_Stat_Hall_Ring_Hi = 0xb4, // -
|
|
||||||
Motor_Stat_Hall_Ring_Lo = 0xb5,
|
|
||||||
|
|
||||||
Motor_Stat_Hall_Lost_Hi = 0xb6, // -
|
|
||||||
Motor_Stat_Hall_Lost_Lo = 0xb7,
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Noise_Hi = 0xc4, // - [Unit:%, Range:0..100, Factor:0.0015259]
|
|
||||||
Motor_Torque_Gauge_Noise_Lo = 0xc5,
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Delay_Hi = 0xc6, // - [Unit:S, Range:0..?, Factor:0.001]
|
|
||||||
Motor_Torque_Gauge_Delay_Lo = 0xc7,
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Speed = 0xc8, // - [Unit:Rpm, Range:0..?, Factor:9.091]
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Voltage_Hi = 0xc9, // - [Unit:V, Range:0..5, Factor:0.000076295, Offset:5]
|
|
||||||
Motor_Torque_Gauge_Voltage_Lo = 0xca,
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Reference_Hi = 0xcb, // - [Unit:V, Range:0..5, Factor:0.000076295, Offset:5]
|
|
||||||
Motor_Torque_Gauge_Reference_Lo = 0xcc,
|
|
||||||
|
|
||||||
Motor_Config_Communication_Mode_Hi = 0xcd, // Sets The Communication Mode. 0 For Can And 0xca01 For I2c
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Gain = 0xce, // - [Unit:%, Range:0..398, Factor:1.5625]
|
|
||||||
|
|
||||||
Motor_Torque_Gauge_Max_Voltage = 0xe0, // Maximum Voltage Allowed For The Sensor. When The Sensor Detect A Voltage Over This Value For Motor.Torque.Gaugemaxvoltagedelay, It Assumes An Electrical Failure And Cuts Assistance [Unit:V, Range:0..5, Factor:0.019608]
|
|
||||||
Motor_Torque_Gauge_Max_Voltage_Delay = 0xe1, // Time After Which A Voltage Over Motor.Torque.Gaugemaxvoltage Is Assumed To Be An Electrical Failure, Cutting Assistance [Unit:S, Range:0..25.5, Factor:0.1]
|
|
||||||
|
|
||||||
Motor_Assist_Level_Offslope_Hi = 0xd0, // Speed At Which The Assist Level Set In The Motor Decreases When The Console Stops Sending Requests (When It Is Removed For Example) [Unit:%/S, Factor:3.05]
|
|
||||||
Motor_Assist_Level_Offslope_Lo = 0xd1,
|
|
||||||
|
|
||||||
Motor_Assist_Regen_Inflex = 0xd2, // Speed From Which Regen Is Not Attenuated [Unit:Rpm, Range:5..?, Factor:9.091]
|
|
||||||
|
|
||||||
Motor_Assist_Maxspeed_Derate_Delta = 0xd3, // Speed Before Maxspeed To Start Derating [Unit:Rpm, Factor:9.091]
|
|
||||||
//{%Endregion}
|
|
||||||
|
|
||||||
|
|
||||||
//{%Region Sensor}
|
|
||||||
ID_Sensor = 0x68,
|
|
||||||
Reg_Sensor_Config_Gauge_Gain_Hi = 0x10,
|
|
||||||
Reg_Sensor_Config_Gauge_Gain_Lo = 0x11,
|
|
||||||
|
|
||||||
Reg_Sensor_Config_Ramp_Up_Steps_Hi = 0x12,
|
|
||||||
Reg_Sensor_Config_Ramp_Up_Steps_Lo = 0x13,
|
|
||||||
|
|
||||||
Reg_Sensor_Config_Decay_Delay_Hi = 0x14,
|
|
||||||
Reg_Sensor_Config_Decay_Delay_Lo = 0x15,
|
|
||||||
|
|
||||||
Reg_Sensor_Config_Decay_Steps_Hi = 0x16,
|
|
||||||
Reg_Sensor_Config_Decay_Steps_Lo = 0x17,
|
|
||||||
|
|
||||||
Reg_Sensor_Config_Speed_Threshold_Hi = 0x18,
|
|
||||||
Reg_Sensor_Config_Speed_Threshold_Lo = 0x19,
|
|
||||||
|
|
||||||
Reg_Sensor_Config_Ramp_Active_Over_Threshold = 0x1a,
|
|
||||||
|
|
||||||
Reg_Sensor_Status_Torque_Voltage = 0x1b, // Torque Sensor Voltage
|
|
||||||
|
|
||||||
Reg_Sensor_Status_Cadence = 0x1c, // Number Of Turns Per Minutes Made With The Pedals
|
|
||||||
|
|
||||||
Reg_Sensor_Status_Output_Voltage = 0x1d, // Voltage Output To The Motor's Gauge Sensor
|
|
||||||
|
|
||||||
Reg_Sensor_Status_Pulse_Counter = 0x1e, // Pulse Counter. Increases When Back Pedaling And Decreases When Forward Pedaling
|
|
||||||
|
|
||||||
Reg_Sensor_Config_Input_Offset = 0x40, // Permit To Offset The Input Value Of The Torque Sensor From +1.64 To -1.65v
|
|
||||||
|
|
||||||
Reg_Sensor_Sn_Location = 0x71, // Location
|
|
||||||
|
|
||||||
Reg_Sensor_Sn_Year = 0x72, // Mfd. Year
|
|
||||||
Reg_Sensor_Sn_Month = 0x73, // Mfd. Month
|
|
||||||
Reg_Sensor_Sn_Day = 0x74, // Mfd. Day
|
|
||||||
|
|
||||||
Reg_Sensor_Sn_Pn_Hi = 0x75, // Partnumber
|
|
||||||
Reg_Sensor_Sn_Pn_Lo = 0x76,
|
|
||||||
|
|
||||||
Reg_Sensor_Sn_Item_Hi = 0x77, // Serial Number
|
|
||||||
Reg_Sensor_Sn_Item_Lo = 0x78,
|
|
||||||
|
|
||||||
Reg_Sensor_Rev_Hw = 0x80, // Hardware Version
|
|
||||||
Reg_Sensor_Rev_Sw = 0x81, // Software Version
|
|
||||||
|
|
||||||
Reg_Sensor_Config_Mode = 0x82, // 0-Thune, 1-Fag
|
|
||||||
|
|
||||||
Reg_Sensor_Rev_Sub = 0x83 // Software Subversion
|
|
||||||
|
|
||||||
};
|
|
||||||
Q_ENUM(ID)
|
|
||||||
|
|
||||||
}; // struct BionxID
|
|
||||||
|
|
||||||
struct BCDevice
|
|
||||||
{
|
|
||||||
Q_GADGET
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum class ID : uint8_t
|
|
||||||
{
|
|
||||||
Invalid = 0,
|
|
||||||
Console = static_cast<uint8_t>( BC::ID::ID_Console_Slave ),
|
|
||||||
Console_Master = uint8_t( BC::ID::ID_Console_Master),
|
|
||||||
Battery = uint8_t( BC::ID::ID_Battery),
|
|
||||||
Motor = uint8_t( BC::ID::ID_Motor ),
|
|
||||||
BIB = uint8_t( BC::ID::ID_Bib ),
|
|
||||||
Sensor = uint8_t( BC::ID::ID_Sensor ),
|
|
||||||
Pimp = uint8_t( BC::ID::ID_Pimp )
|
|
||||||
};
|
|
||||||
Q_ENUM(ID)
|
|
||||||
};
|
|
||||||
|
|
||||||
using namespace Qt::Literals::StringLiterals; // Für _L1
|
|
||||||
|
|
||||||
namespace BCTags
|
|
||||||
{
|
|
||||||
inline constexpr auto Device = "Device"_L1;
|
|
||||||
inline constexpr auto ID = "ID"_L1;
|
|
||||||
inline constexpr auto Label = "Label"_L1;
|
|
||||||
inline constexpr auto Default = "Default"_L1;
|
|
||||||
inline constexpr auto Current = "Current"_L1;
|
|
||||||
inline constexpr auto Enabled = "Enabled"_L1;
|
|
||||||
inline constexpr auto UnitType = "UnitType"_L1;
|
|
||||||
inline constexpr auto Min = "Min"_L1;
|
|
||||||
inline constexpr auto Max = "Max"_L1;
|
|
||||||
inline constexpr auto Factor = "Factor"_L1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BC_H
|
|
||||||
@@ -50,8 +50,8 @@ BCDataManager::BCDataManager(QObject *parent)
|
|||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
//qRegisterMetaType<BCDataValue*>("BCDataValue*");
|
//qRegisterMetaType<BCValue*>("BCValue*");
|
||||||
//qRegisterMetaType<BCDataValue*>();
|
//qRegisterMetaType<BCValue*>();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ void BCDataManager::loadXmlBikeDeviceData(BCDevice::ID deviceID)
|
|||||||
};
|
};
|
||||||
|
|
||||||
// nur gültige Werte sind vorhanden und können gespeichert werden
|
// nur gültige Werte sind vorhanden und können gespeichert werden
|
||||||
std::optional<BCDataValue> newValue = makeDataValue( deviceID, params );
|
std::optional<BCValue> newValue = makeDataValue( deviceID, params );
|
||||||
if(newValue)
|
if(newValue)
|
||||||
currentValues.push_back( *newValue );
|
currentValues.push_back( *newValue );
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ void BCDataManager::loadXmlBikeDeviceData(BCDevice::ID deviceID)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<BCDataValue> BCDataManager::makeDataValue( BCDevice::ID deviceID, const BCDataParams& params )
|
std::optional<BCValue> BCDataManager::makeDataValue( BCDevice::ID deviceID, const BCDataParams& params )
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -242,7 +242,7 @@ std::optional<BCDataValue> BCDataManager::makeDataValue( BCDevice::ID deviceID,
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::optional<BCDataValue> newValue;
|
std::optional<BCValue> newValue;
|
||||||
|
|
||||||
std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
|
std::optional<quint64> IDVal = s_bcValueEnum.keyToValue64( params.ID.toLatin1().constData() );
|
||||||
qDebug() << " --- should create: " << params.Label << ": " << params.UnitType;
|
qDebug() << " --- should create: " << params.Label << ": " << params.UnitType;
|
||||||
@@ -253,7 +253,7 @@ std::optional<BCDataValue> BCDataManager::makeDataValue( BCDevice::ID deviceID,
|
|||||||
{
|
{
|
||||||
|
|
||||||
const BCValueType* valueType = s_bcDataTypes[params.UnitType];
|
const BCValueType* valueType = s_bcDataTypes[params.UnitType];
|
||||||
newValue = BCDataValue( valueType, deviceID, static_cast<BC::ID>(IDVal.value()) );
|
newValue = BCValue( valueType, deviceID, static_cast<BC::ID>(IDVal.value()) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
setIfExists( params.Factor, newValue.factor );
|
setIfExists( params.Factor, newValue.factor );
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ protected:
|
|||||||
|
|
||||||
void loadXmlBikeDeviceData( BCDevice::ID deviceID );
|
void loadXmlBikeDeviceData( BCDevice::ID deviceID );
|
||||||
|
|
||||||
std::optional<BCDataValue> makeDataValue( BCDevice::ID deviceID, const BCDataParams& params );
|
std::optional<BCValue> makeDataValue( BCDevice::ID deviceID, const BCDataParams& params );
|
||||||
|
|
||||||
using BCValueTypeMap = QMap<QString,BCValueType*>;
|
using BCValueTypeMap = QMap<QString,BCValueType*>;
|
||||||
|
|
||||||
|
|||||||
@@ -43,25 +43,25 @@
|
|||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include "bcitemdelegate.h"
|
#include "bcdelegate.h"
|
||||||
#include "bcdatavalue.h"
|
#include "bcvalue.h"
|
||||||
#include "qapplication.h"
|
#include "qapplication.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BCItemDelegate::BCItemDelegate(QTableView* view)
|
BCDelegate::BCDelegate(QTableView* view)
|
||||||
: QStyledItemDelegate(view), _view{view}
|
: QStyledItemDelegate(view), _view{view}
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString BCItemDelegate::displayText(const QVariant& dataValue, const QLocale& locale) const
|
QString BCDelegate::displayText(const QVariant& dataValue, const QLocale& locale) const
|
||||||
{
|
{
|
||||||
// Wir prüfen, ob im Variant unser Struct steckt
|
// Wir prüfen, ob im Variant unser Struct steckt
|
||||||
if (dataValue.canConvert<BCDataValue*>())
|
if (dataValue.canConvert<BCValue*>())
|
||||||
{
|
{
|
||||||
BCDataValue& bc = *dataValue.value<BCDataValue*>();
|
BCValue& bc = *dataValue.value<BCValue*>();
|
||||||
qDebug() << " --- YES: " << bc.label;
|
qDebug() << " --- YES: " << bc.label;
|
||||||
// Hier bauen wir den String zusammen, den man sieht,
|
// Hier bauen wir den String zusammen, den man sieht,
|
||||||
// wenn KEIN Editor offen ist.
|
// wenn KEIN Editor offen ist.
|
||||||
@@ -78,13 +78,13 @@ QString BCItemDelegate::displayText(const QVariant& dataValue, const QLocale& lo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWidget *BCItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
QWidget *BCDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
QVariant rawData = index.data(Qt::EditRole);
|
QVariant rawData = index.data(Qt::EditRole);
|
||||||
//if (!rawData.canConvert<BCDataValue*>())
|
//if (!rawData.canConvert<BCValue*>())
|
||||||
return QStyledItemDelegate::createEditor(parent, option, index);
|
return QStyledItemDelegate::createEditor(parent, option, index);
|
||||||
/*
|
/*
|
||||||
const BCDataValue& bc = *rawData.value<BCDataValue*>();
|
const BCValue& bc = *rawData.value<BCValue*>();
|
||||||
|
|
||||||
// Nur bei Integern den Slider-Editor bauen
|
// Nur bei Integern den Slider-Editor bauen
|
||||||
if (bc.value.typeId() == QMetaType::Int)
|
if (bc.value.typeId() == QMetaType::Int)
|
||||||
@@ -128,10 +128,10 @@ QWidget *BCItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewIte
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCItemDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
|
void BCDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
// Daten vom Model in den Editor laden
|
// Daten vom Model in den Editor laden
|
||||||
const BCDataValue& bc = *index.data(Qt::EditRole).value<BCDataValue*>();
|
const BCValue& bc = *index.data(Qt::EditRole).value<BCValue*>();
|
||||||
|
|
||||||
QSlider *slider = editor->findChild<QSlider*>("slider");
|
QSlider *slider = editor->findChild<QSlider*>("slider");
|
||||||
QLabel *lblUnit = editor->findChild<QLabel*>("lblUnit");
|
QLabel *lblUnit = editor->findChild<QLabel*>("lblUnit");
|
||||||
@@ -147,7 +147,7 @@ void BCItemDelegate::setEditorData(QWidget *editor, const QModelIndex& index) co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const
|
void BCDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
// Daten vom Editor zurück ins Model speichern (Beim Schließen)
|
// Daten vom Editor zurück ins Model speichern (Beim Schließen)
|
||||||
QSlider *slider = editor->findChild<QSlider*>("slider");
|
QSlider *slider = editor->findChild<QSlider*>("slider");
|
||||||
@@ -160,12 +160,12 @@ void BCItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
void BCDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
editor->setGeometry(option.rect);
|
editor->setGeometry(option.rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize BCItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const
|
QSize BCDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
return QStyledItemDelegate::sizeHint(option,index);
|
return QStyledItemDelegate::sizeHint(option,index);
|
||||||
/*
|
/*
|
||||||
@@ -179,7 +179,7 @@ QSize BCItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelI
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BCItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
void BCDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
// 1. Standard-Zeichnen (Text, Hintergrund, Selection) durchführen
|
// 1. Standard-Zeichnen (Text, Hintergrund, Selection) durchführen
|
||||||
@@ -246,7 +246,7 @@ void BCItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCItemDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
void BCDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
@@ -283,7 +283,7 @@ void BCItemDelegate::paintHighlightRow(QPainter* painter, const QStyleOptionView
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BCItemDelegate::onHighlightRow(int row)
|
void BCDelegate::onHighlightRow(int row)
|
||||||
{
|
{
|
||||||
qDebug() << " --- should highlight: " << row;
|
qDebug() << " --- should highlight: " << row;
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ void BCItemDelegate::onHighlightRow(int row)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Optional: alle Highlights sofort clearen
|
// Optional: alle Highlights sofort clearen
|
||||||
void BCItemDelegate::clearAllHighlights()
|
void BCDelegate::clearAllHighlights()
|
||||||
{
|
{
|
||||||
for(auto* anim : std::as_const(m_rowAnimations))
|
for(auto* anim : std::as_const(m_rowAnimations))
|
||||||
{
|
{
|
||||||
@@ -348,7 +348,7 @@ void BCItemDelegate::clearAllHighlights()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCItemDelegate::updateRow(int row)
|
void BCDelegate::updateRow(int row)
|
||||||
{
|
{
|
||||||
if (_view && _view->model() && row >= 0)
|
if (_view && _view->model() && row >= 0)
|
||||||
{
|
{
|
||||||
@@ -360,7 +360,7 @@ void BCItemDelegate::updateRow(int row)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BCItemDelegate::formatDisplayString(const QModelIndex& index) const
|
QString BCDelegate::formatDisplayString(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QString();
|
return QString();
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef BCITEMDELEGATE_H
|
#ifndef BCDELEGATE_H
|
||||||
#define BCITEMDELEGATE_H
|
#define BCDELEGATE_H
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
@@ -39,14 +39,14 @@ class QPropertyAnimation;
|
|||||||
class QVariantAnimation;
|
class QVariantAnimation;
|
||||||
class QTableView;
|
class QTableView;
|
||||||
|
|
||||||
class BCItemDelegate : public QStyledItemDelegate
|
class BCDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(qreal highlightOpacity READ highlightOpacity WRITE setHighlightOpacity)
|
Q_PROPERTY(qreal highlightOpacity READ highlightOpacity WRITE setHighlightOpacity)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit BCItemDelegate(QTableView* view );
|
explicit BCDelegate(QTableView* view );
|
||||||
|
|
||||||
QString displayText(const QVariant& dataValue, const QLocale& locale) const override;
|
QString displayText(const QVariant& dataValue, const QLocale& locale) const override;
|
||||||
|
|
||||||
@@ -102,4 +102,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // BCITEMDELEGATE_H
|
#endif // BCDELEGATE_H
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <_mingw_mac.h>
|
||||||
#include <bcdevicepanel.h>
|
#include <bcdevicepanel.h>
|
||||||
|
|
||||||
BCDevicePanel::BCDevicePanel(QWidget *parent)
|
BCDevicePanel::BCDevicePanel(QWidget *parent)
|
||||||
@@ -83,11 +84,17 @@ QTableView* BCDevicePanel::getValueView()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const BCValueList& BCDevicePanel::getValueList()
|
const BCValueList& BCDevicePanel::getValueListX()
|
||||||
{
|
{
|
||||||
return _valueModel.getValueList();
|
return _valueModel.getValueList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BCValueModel& BCDevicePanel::getValueModel()
|
||||||
|
{
|
||||||
|
return _valueModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// __FIX ist das ok so?
|
||||||
void BCDevicePanel::onValueListReady( BCDevice::ID deviceID, BCValueList valueList )
|
void BCDevicePanel::onValueListReady( BCDevice::ID deviceID, BCValueList valueList )
|
||||||
{
|
{
|
||||||
qDebug() << " --- onValueListReady: " << getHeaderText() <<" : " << deviceID << ": " << valueList.size();
|
qDebug() << " --- onValueListReady: " << getHeaderText() <<" : " << deviceID << ": " << valueList.size();
|
||||||
@@ -95,6 +102,8 @@ void BCDevicePanel::onValueListReady( BCDevice::ID deviceID, BCValueList valueLi
|
|||||||
_valueModel.takeValueList( valueList );
|
_valueModel.takeValueList( valueList );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QTableView* BCDevicePanel::setValueView()
|
QTableView* BCDevicePanel::setValueView()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,8 +50,10 @@ public:
|
|||||||
|
|
||||||
void setDeviceID( BCDevice::ID deviceID );
|
void setDeviceID( BCDevice::ID deviceID );
|
||||||
BCDevice::ID getDeviceID() const;
|
BCDevice::ID getDeviceID() const;
|
||||||
|
|
||||||
QTableView* getValueView();
|
QTableView* getValueView();
|
||||||
const BCValueList& getValueList();
|
const BCValueList& getValueListX();
|
||||||
|
BCValueModel &getValueModel();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "qassert.h"
|
#include "qassert.h"
|
||||||
#include <bcmainwindow.h>
|
#include <bcmainwindow.h>
|
||||||
#include <bcitemdelegate.h>
|
#include <bcdelegate.h>
|
||||||
#include <ui_bcmainwindow.h>
|
#include <ui_bcmainwindow.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -45,8 +45,8 @@ BCMainWindow::BCMainWindow(QWidget *parent)
|
|||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
// WICHTIG: Registriere sowohl das Struct als auch die LISTE des Structs
|
// WICHTIG: Registriere sowohl das Struct als auch die LISTE des Structs
|
||||||
qRegisterMetaType<BCDataValue>("BCDataValue");
|
qRegisterMetaType<BCValue>("BCValue");
|
||||||
qRegisterMetaType<QList<BCDataValue>>("BCValueList");
|
qRegisterMetaType<QList<BCValue>>("BCValueList");
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
initMainWindow();
|
initMainWindow();
|
||||||
@@ -121,14 +121,14 @@ void BCMainWindow::initMainWindow()
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BCItemDelegate* _delegate = new BCItemDelegate( _valueView);
|
BCDelegate* _delegate = new BCDelegate( _valueView);
|
||||||
//_delegate = new AnimatedDelegate(_valueView );
|
//_delegate = new AnimatedDelegate(_valueView );
|
||||||
_valueView->setItemDelegate( _delegate );
|
_valueView->setItemDelegate( _delegate );
|
||||||
|
|
||||||
|
|
||||||
// Verwendung:
|
// Verwendung:
|
||||||
|
|
||||||
connect(_delegate, &BCItemDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update));
|
connect(_delegate, &BCDelegate::viewUpdateNeeded, _valueView->viewport(), QOverload<>::of(&QWidget::update));
|
||||||
|
|
||||||
|
|
||||||
//_valueView->setItemDelegate(_delegate);
|
//_valueView->setItemDelegate(_delegate);
|
||||||
@@ -139,7 +139,7 @@ void BCMainWindow::initMainWindow()
|
|||||||
|
|
||||||
// besser: model::emit dataChanged
|
// besser: model::emit dataChanged
|
||||||
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
||||||
connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCItemDelegate::onHighlightRow );
|
connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCDelegate::onHighlightRow );
|
||||||
connect( _connectButton, &QPushButton::clicked, transmitter, &BCTransmitter::onToggleConnectionState );
|
connect( _connectButton, &QPushButton::clicked, transmitter, &BCTransmitter::onToggleConnectionState );
|
||||||
connect( _syncButton, &QPushButton::clicked, &_dataManager, &BCMainWindow::onSyncFromDevice );
|
connect( _syncButton, &QPushButton::clicked, &_dataManager, &BCMainWindow::onSyncFromDevice );
|
||||||
*/
|
*/
|
||||||
@@ -147,9 +147,11 @@ void BCMainWindow::initMainWindow()
|
|||||||
|
|
||||||
// besser: model::emit dataChanged
|
// besser: model::emit dataChanged
|
||||||
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
// also: emit dataChanged(index, index, {Qt::DisplayRole, Qt::EditRole, ValueRole});
|
||||||
//connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCItemDelegate::onHighlightRow );
|
//connect( &_dataManager, &BCMainWindow::valueTouched, _delegate, &BCDelegate::onHighlightRow );
|
||||||
connect( _connectButton, &QPushButton::clicked, &_transmitter, &BCTransmitter::onToggleConnectionState );
|
connect( _connectButton, &QPushButton::clicked, &_transmitter, &BCTransmitter::onToggleConnectionState );
|
||||||
connect( _syncButton, &QPushButton::clicked, this, &BCMainWindow::onSyncFromDevice );
|
connect( _syncButton, &QPushButton::clicked, this, &BCMainWindow::onSyncFromDevice );
|
||||||
|
connect( &_transmitter, &BCTransmitter::valueUpdated, this, &BCMainWindow::onValueUpdated );
|
||||||
|
|
||||||
// die Daten des eBikes laden
|
// die Daten des eBikes laden
|
||||||
_dataManager.loadXmlBikeData(":/bikeinfo.xml"_L1);
|
_dataManager.loadXmlBikeData(":/bikeinfo.xml"_L1);
|
||||||
|
|
||||||
@@ -191,7 +193,7 @@ void BCMainWindow::onValueListReady( BCDevice::ID deviceID )
|
|||||||
void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID )
|
void BCMainWindow::onShowDevicePanel( BCDevice::ID deviceID )
|
||||||
{
|
{
|
||||||
qDebug() << " --- onShowDevicePanel:" << deviceID;
|
qDebug() << " --- onShowDevicePanel:" << deviceID;
|
||||||
if( _devicePanels.contains( deviceID ) )
|
if( _devicePanels.contains( deviceID ) )
|
||||||
{
|
{
|
||||||
BCDevicePanel* nxtPanel = _devicePanels[deviceID];
|
BCDevicePanel* nxtPanel = _devicePanels[deviceID];
|
||||||
if( nxtPanel != _currentPanel )
|
if( nxtPanel != _currentPanel )
|
||||||
@@ -220,9 +222,16 @@ void BCMainWindow::onConnectButtonToggled(bool checked )
|
|||||||
//_dataManager.setDriverConnectionState( checked );
|
//_dataManager.setDriverConnectionState( checked );
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCMainWindow::onvalueStateChanged(int id, bool success)
|
void BCMainWindow::onValueUpdated(BCDevice::ID deviceID, int index, BC::State state, const QString& newValue )
|
||||||
{
|
{
|
||||||
qDebug() << "[Manager] Command" << id << "finished. Success:" << success;
|
qDebug() << "Reply: from: " << deviceID << " at: " << index << "finished. Success:" << state << " on:" << newValue;
|
||||||
|
if( _devicePanels.contains( deviceID ) )
|
||||||
|
{
|
||||||
|
BCDevicePanel& panel = *_devicePanels[deviceID];
|
||||||
|
panel.getValueModel().onValueUpdated( index, state, newValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
//_devicePanels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCMainWindow::onRunnerMessage(const QString &msg)
|
void BCMainWindow::onRunnerMessage(const QString &msg)
|
||||||
@@ -232,7 +241,7 @@ void BCMainWindow::onRunnerMessage(const QString &msg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// __fix move this to devicePanel
|
||||||
void BCMainWindow::onSyncFromDevice()
|
void BCMainWindow::onSyncFromDevice()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -240,11 +249,11 @@ void BCMainWindow::onSyncFromDevice()
|
|||||||
|
|
||||||
qDebug() << " ---Syncing";
|
qDebug() << " ---Syncing";
|
||||||
|
|
||||||
const BCValueList& currentList =_currentPanel->getValueList();
|
const BCValueList& currentList =_currentPanel->getValueListX();
|
||||||
|
|
||||||
// alle einzeln? echt jetzt?
|
// alle einzeln? echt jetzt?
|
||||||
|
|
||||||
for( const BCDataValue& value : currentList )
|
for( const BCValue& value : currentList )
|
||||||
{
|
{
|
||||||
qDebug() << " --- value: " << value.label;
|
qDebug() << " --- value: " << value.label;
|
||||||
|
|
||||||
@@ -254,7 +263,7 @@ void BCMainWindow::onSyncFromDevice()
|
|||||||
//_transmitter.enqueueValueCommand( value );
|
//_transmitter.enqueueValueCommand( value );
|
||||||
emit sendValueCommand( BC::OpID::ReadValue, &value);
|
emit sendValueCommand( BC::OpID::ReadValue, &value);
|
||||||
|
|
||||||
emit valueTouched( value.rowInModel );
|
emit valueTouched( value.indexRow );
|
||||||
|
|
||||||
bc::processEventsFor(500);
|
bc::processEventsFor(500);
|
||||||
|
|
||||||
|
|||||||
@@ -58,16 +58,16 @@ public slots:
|
|||||||
void onConnectButtonToggled(bool active );
|
void onConnectButtonToggled(bool active );
|
||||||
|
|
||||||
// Slots für Rückmeldungen vom Runner
|
// Slots für Rückmeldungen vom Runner
|
||||||
void onvalueStateChanged(int id, bool success);
|
void onValueUpdated( BCDevice::ID deviceID, int index, BC::State state, const QString& newValue="" );
|
||||||
void onRunnerMessage(const QString &msg);
|
void onRunnerMessage(const QString &msg);
|
||||||
void onSyncFromDevice();
|
void onSyncFromDevice();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
// Internes Signal, um Daten an den Worker Thread zu senden
|
// Internes Signal, um Daten an den Worker Thread zu senden
|
||||||
void sendValueCommand( BC::OpID, const BCDataValue* cmd);
|
void sendValueCommand( BC::OpID, const BCValue* cmd);
|
||||||
//void valuedTouched(const BCDataValue& cmd);
|
//void valuedTouched(const BCValue& cmd);
|
||||||
void valueTouched(int rowInModel );
|
void valueTouched(int indexRow );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ void BCTransmitter::onToggleConnectionState( bool connect )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCDataValue* value)
|
void BCTransmitter::enqueueValueOp(BC::OpID opID, const BCValue* value)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
_valueQueue.enqueue( value );
|
_valueQueue.enqueue( value );
|
||||||
@@ -116,7 +116,7 @@ void BCTransmitter::processValueOp( BC::OpID opID )
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
const BCDataValue* currentValue{};
|
const BCValue* currentValue{};
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
if (_valueQueue.isEmpty())
|
if (_valueQueue.isEmpty())
|
||||||
@@ -130,9 +130,14 @@ void BCTransmitter::processValueOp( BC::OpID opID )
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Abkürzung
|
||||||
|
const BCValue& val = *currentValue;
|
||||||
|
// Value ist 'under construction'
|
||||||
|
emit valueUpdated( val.deviceID, val.indexRow, BC::State::Locked );
|
||||||
if( opID == BC::OpID::ReadValue )
|
if( opID == BC::OpID::ReadValue )
|
||||||
{
|
{
|
||||||
QString result = currentValue->readRawValueX( *this );
|
QString result = currentValue->readRawValueX( *this );
|
||||||
|
emit valueUpdated( val.deviceID, val.indexRow, BC::State::InSync, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( opID == BC::OpID::WriteValue )
|
else if( opID == BC::OpID::WriteValue )
|
||||||
@@ -148,21 +153,23 @@ void BCTransmitter::processValueOp( BC::OpID opID )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//emit commandFinished(cmd.id, true);
|
//emit valueStateChanged(cmd.id, true);
|
||||||
//emit commandFinished(0, true);
|
//emit valueStateChanged(0, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BCTransmitter::readRawByte( uint32_t deviceID, uint8_t registerID ) const
|
uint32_t BCTransmitter::readRawByte( uint32_t deviceID, uint8_t registerID ) const
|
||||||
{
|
{
|
||||||
|
uint32_t result{};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _canDriver.readRawByte( deviceID, registerID );
|
result = _canDriver.readRawByte( deviceID, registerID );
|
||||||
}
|
}
|
||||||
catch ( BCException& exception )
|
catch ( BCException& exception )
|
||||||
{
|
{
|
||||||
qDebug() << " -- OUCH: read exception: " << exception.what();
|
qDebug() << " -- OUCH: read exception: " << exception.what();
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#include <bcdatavalue.h>
|
#include <bcvalue.h>
|
||||||
#include <bccandrivertinycan.h>
|
#include <bccandrivertinycan.h>
|
||||||
|
|
||||||
// template ...
|
// template ...
|
||||||
@@ -56,17 +56,17 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onToggleConnectionState( bool connect );
|
void onToggleConnectionState( bool connect );
|
||||||
void enqueueValueOp(BC::OpID opID, const BCDataValue* value );
|
void enqueueValueOp(BC::OpID opID, const BCValue* value );
|
||||||
void processValueOp(BC::OpID opID);
|
void processValueOp(BC::OpID opID);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void commandFinished(int id, bool success);
|
void valueUpdated(BCDevice::ID deviceID, int index, BC::State state, const QString& newValue="" );
|
||||||
void messageLogged(const QString& msg);
|
void messageLogged(const QString& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
using BCDataQueue = QQueue<const BCDataValue*>;
|
using BCDataQueue = QQueue<const BCValue*>;
|
||||||
|
|
||||||
BCDataQueue _valueQueue;
|
BCDataQueue _valueQueue;
|
||||||
QMutex _mutex;
|
QMutex _mutex;
|
||||||
|
|||||||
@@ -32,19 +32,19 @@
|
|||||||
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
#include <bcdatavalue.h>
|
#include <bcvalue.h>
|
||||||
#include <bcvaluetype.h>
|
#include <bcvaluetype.h>
|
||||||
|
|
||||||
///-------------------------------
|
///-------------------------------
|
||||||
|
|
||||||
|
|
||||||
BCDataValue::BCDataValue(const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_)
|
BCValue::BCValue(const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_)
|
||||||
: valueType{valueType_}, deviceID{deviceID_}, registerID{registerID_}
|
: valueType{valueType_}, deviceID{deviceID_}, registerID{registerID_}
|
||||||
{
|
{
|
||||||
visibleValue = "--";
|
visibleValue = "--";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BCDataValue::readRawValueX( const BCAbstractTransmitter& transmitter ) const
|
QString BCValue::readRawValueX( const BCAbstractTransmitter& transmitter ) const
|
||||||
{
|
{
|
||||||
qDebug() << " --- READ X!";
|
qDebug() << " --- READ X!";
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ QString BCDataValue::readRawValueX( const BCAbstractTransmitter& transmitter ) c
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCDataValue::writeRawValueX( const BCAbstractTransmitter& transmitter ) const
|
void BCValue::writeRawValueX( const BCAbstractTransmitter& transmitter ) const
|
||||||
{
|
{
|
||||||
qDebug() << " --- WRITE X!";
|
qDebug() << " --- WRITE X!";
|
||||||
}
|
}
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef BCDATAVALUE_H
|
#ifndef BCVALUE_H
|
||||||
#define BCDATAVALUE_H
|
#define BCVALUE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -69,12 +69,12 @@ public:
|
|||||||
|
|
||||||
class BCValueType;
|
class BCValueType;
|
||||||
|
|
||||||
class BCDataValue
|
class BCValue
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
BCDataValue( const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
|
BCValue( const BCValueType* valueType_, BCDevice::ID deviceID_, BC::ID registerID_ );
|
||||||
|
|
||||||
QString readRawValueX( const BCAbstractTransmitter& transmitter ) const;
|
QString readRawValueX( const BCAbstractTransmitter& transmitter ) const;
|
||||||
void writeRawValueX( const BCAbstractTransmitter& transmitter ) const;
|
void writeRawValueX( const BCAbstractTransmitter& transmitter ) const;
|
||||||
@@ -83,17 +83,18 @@ public:
|
|||||||
// später
|
// später
|
||||||
//protected:
|
//protected:
|
||||||
|
|
||||||
|
mutable BC::State state{BC::State::Invalid};
|
||||||
//const BCValueType& valueType;
|
//const BCValueType& valueType;
|
||||||
//BCValueTypeCRef valueType;
|
//BCValueTypeCRef valueType;
|
||||||
const BCValueType* valueType{};
|
const BCValueType* valueType{};
|
||||||
BCDevice::ID deviceID{BCDevice::ID::Invalid};
|
BCDevice::ID deviceID{BCDevice::ID::Invalid};
|
||||||
BC::ID registerID{BC::ID::Invalid};
|
BC::ID registerID{BC::ID::Invalid};
|
||||||
int rowInModel{-1};
|
int indexRow{-1};
|
||||||
QString label;
|
QString label;
|
||||||
// ??
|
// ??
|
||||||
mutable QString visibleValue;
|
mutable QString visibleValue;
|
||||||
QVariant defaultValue;
|
QVariant defaultValue;
|
||||||
|
//??
|
||||||
bool inSync{false};
|
bool inSync{false};
|
||||||
bool readOnly{false};
|
bool readOnly{false};
|
||||||
|
|
||||||
@@ -101,12 +102,12 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
// ?? ist das nötig?
|
// ?? ist das nötig?
|
||||||
Q_DECLARE_METATYPE(BCDataValue*)
|
Q_DECLARE_METATYPE(BCValue*)
|
||||||
|
|
||||||
|
|
||||||
//using BCValueList = QList<BCDataValue>;
|
//using BCValueList = QList<BCValue>;
|
||||||
|
|
||||||
class BCValueList : public QList<BCDataValue>
|
class BCValueList : public QList<BCValue>
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -117,13 +118,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
BCValueList(const BCValueList& other)
|
BCValueList(const BCValueList& other)
|
||||||
: QList<BCDataValue>(other)
|
: QList<BCValue>(other)
|
||||||
{
|
{
|
||||||
qDebug() << "BC: Copy from: " << &other << "to" << this;
|
qDebug() << "BC: Copy from: " << &other << "to" << this;
|
||||||
}
|
}
|
||||||
|
|
||||||
BCValueList(BCValueList&& other) noexcept
|
BCValueList(BCValueList&& other) noexcept
|
||||||
: QList<BCDataValue>( other )
|
: QList<BCValue>( other )
|
||||||
{
|
{
|
||||||
qDebug() << "Move from: " << &other << "to" << this;
|
qDebug() << "Move from: " << &other << "to" << this;
|
||||||
}
|
}
|
||||||
@@ -131,14 +132,14 @@ public:
|
|||||||
// Copy Assignment Operator
|
// Copy Assignment Operator
|
||||||
BCValueList& operator=(const BCValueList& other)
|
BCValueList& operator=(const BCValueList& other)
|
||||||
{
|
{
|
||||||
QList<BCDataValue>::operator=( other );
|
QList<BCValue>::operator=( other );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move Assignment Operator
|
// Move Assignment Operator
|
||||||
BCValueList& operator=(BCValueList&& other) noexcept
|
BCValueList& operator=(BCValueList&& other) noexcept
|
||||||
{
|
{
|
||||||
QList<BCDataValue>::operator=( other );
|
QList<BCValue>::operator=( other );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,4 +171,4 @@ constexpr auto to_u(E e) noexcept {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BCDATAVALUE_H
|
#endif // BCVALUE_H
|
||||||
@@ -40,7 +40,7 @@ BCValueModel::BCValueModel(QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BCValueModel::addValue(const BCDataValue& val)
|
void BCValueModel::addValue(const BCValue& val)
|
||||||
{
|
{
|
||||||
int row = _valueList.size();
|
int row = _valueList.size();
|
||||||
beginInsertRows(QModelIndex(), row, row);
|
beginInsertRows(QModelIndex(), row, row);
|
||||||
@@ -49,7 +49,7 @@ void BCValueModel::addValue(const BCDataValue& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const BCValueList& BCValueModel::getValueList()
|
const BCValueList& BCValueModel::getValueList() const
|
||||||
{
|
{
|
||||||
return _valueList;
|
return _valueList;
|
||||||
}
|
}
|
||||||
@@ -63,6 +63,33 @@ void BCValueModel::takeValueList(BCValueList& newValueList)
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BCValueModel::onValueUpdated( int row, BC::State state, const QString& newValue )
|
||||||
|
{
|
||||||
|
qDebug() << " Panel update: " << newValue;
|
||||||
|
const BCValueList& valueList = getValueList();
|
||||||
|
if( row > -1 && row < valueList.size() )
|
||||||
|
{
|
||||||
|
bool valueChanged = false;
|
||||||
|
const BCValue& value = valueList[row];
|
||||||
|
if( value.state != state )
|
||||||
|
{
|
||||||
|
valueChanged = true;
|
||||||
|
value.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !newValue.isEmpty() && newValue != value.visibleValue )
|
||||||
|
{
|
||||||
|
valueChanged = true;
|
||||||
|
value.visibleValue = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( valueChanged )
|
||||||
|
{
|
||||||
|
QModelIndex idx = index(row,1);
|
||||||
|
emit dataChanged(idx, idx, {Qt::DisplayRole});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int BCValueModel::rowCount(const QModelIndex& parent) const
|
int BCValueModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
@@ -125,8 +152,8 @@ if (!index.isValid() || index.row() >= static_cast<int>(m_items.size()))
|
|||||||
if (!index.isValid() || row >= _valueList.size())
|
if (!index.isValid() || row >= _valueList.size())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
BCDataValue& entry = const_cast<BCDataValue&>(_valueList.at( row ));
|
BCValue& entry = const_cast<BCValue&>(_valueList.at( row ));
|
||||||
entry.rowInModel = row;
|
entry.indexRow = row;
|
||||||
|
|
||||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||||
{
|
{
|
||||||
@@ -153,7 +180,7 @@ bool BCValueModel::setData(const QModelIndex& index, const QVariant& value, int
|
|||||||
{
|
{
|
||||||
if (index.isValid() && role == Qt::EditRole)
|
if (index.isValid() && role == Qt::EditRole)
|
||||||
{
|
{
|
||||||
BCDataValue& item = _valueList[index.row()];
|
BCValue& item = _valueList[index.row()];
|
||||||
|
|
||||||
// Wir erwarten hier nur den Value-Teil (vom Slider/Editor)
|
// Wir erwarten hier nur den Value-Teil (vom Slider/Editor)
|
||||||
// Checken ob Int oder Double
|
// Checken ob Int oder Double
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#define BCVALUEMODEL_H
|
#define BCVALUEMODEL_H
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
#include <bcdatavalue.h>
|
#include <bcvalue.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Das BCValueModel dient als Interface zu den eigentlichen Daten,
|
* @brief Das BCValueModel dient als Interface zu den eigentlichen Daten,
|
||||||
@@ -52,10 +52,10 @@ public:
|
|||||||
|
|
||||||
explicit BCValueModel(QObject *parent = nullptr);
|
explicit BCValueModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
void addValue(const BCDataValue& val);
|
void addValue(const BCValue& val);
|
||||||
|
|
||||||
void takeValueList(BCValueList& valueList);
|
void takeValueList(BCValueList& valueList);
|
||||||
const BCValueList& getValueList();
|
const BCValueList& getValueList() const;
|
||||||
|
|
||||||
// Pure Virtual Functions von QAbstractTableModel
|
// Pure Virtual Functions von QAbstractTableModel
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
@@ -68,7 +68,11 @@ public:
|
|||||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||||
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
||||||
|
|
||||||
private:
|
public slots:
|
||||||
|
|
||||||
|
void onValueUpdated( int index, BC::State state, const QString& newValue="" );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
// Die eigentlichen Werte wohnen im tatsächlich hier, im Model.
|
// Die eigentlichen Werte wohnen im tatsächlich hier, im Model.
|
||||||
BCValueList _valueList;
|
BCValueList _valueList;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <bcvaluetype.h>
|
#include <bcvaluetype.h>
|
||||||
#include <bcdatavalue.h>
|
#include <bcvalue.h>
|
||||||
|
|
||||||
|
|
||||||
BCValueType::BCValueType()
|
BCValueType::BCValueType()
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
#include <bc.h>
|
#include <bc.h>
|
||||||
|
|
||||||
class BCAbstractTransmitter;
|
class BCAbstractTransmitter;
|
||||||
class BCDataValue;
|
class BCValue;
|
||||||
|
|
||||||
using optDouble = std::optional<double>;
|
using optDouble = std::optional<double>;
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
optDouble max;
|
optDouble max;
|
||||||
|
|
||||||
virtual QString createStringValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID ) const = 0;
|
virtual QString createStringValue( const BCAbstractTransmitter& transmitter, uint32_t deviceID, uint8_t registerID ) const = 0;
|
||||||
//virtual void writeValue( const BCAbstractTransmitter& transmitter, BCDataValue& value ) = 0;
|
//virtual void writeValue( const BCAbstractTransmitter& transmitter, BCValue& value ) = 0;
|
||||||
|
|
||||||
virtual QString formatValue( uint32_t value ) const;
|
virtual QString formatValue( uint32_t value ) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user