Create dummy devices, part I
This commit is contained in:
@@ -1,18 +1,9 @@
|
|||||||
#include <bccandrivertinycan.h>
|
|
||||||
|
|
||||||
|
|
||||||
//#define UNLIMITED_SPEED_VALUE 70 /* Km/h */
|
|
||||||
//#define UNLIMITED_MIN_SPEED_VALUE 30 /* Km/h */
|
|
||||||
//#define MAX_THROTTLE_SPEED_VALUE 70 /* Km/h */
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
#include <bccandrivertinycan.h>
|
#include <bccandrivertinycan.h>
|
||||||
|
|
||||||
|
|
||||||
#include <can_drv.h>
|
#include <can_drv.h>
|
||||||
//#include "mhstcan.h"
|
|
||||||
|
|
||||||
BCCanDriverTinyCan::BCCanDriverTinyCan( QObject* parent )
|
BCCanDriverTinyCan::BCCanDriverTinyCan( QObject* parent )
|
||||||
: BCCanDriver(parent )
|
: BCCanDriver(parent )
|
||||||
@@ -121,6 +112,12 @@ bcdata_t BCCanDriverTinyCan::readRawValue( BCDevice::ID deviceID, BC::ID registe
|
|||||||
if( getState() != DriverState::Ready)
|
if( getState() != DriverState::Ready)
|
||||||
throw BCException( "readRawValue error: driver not loaded." );
|
throw BCException( "readRawValue error: driver not loaded." );
|
||||||
|
|
||||||
|
//bcdata_t result = transmitter.readRawValue( deviceID, registerID );
|
||||||
|
bcdata_t myRandomByte = static_cast<quint8>(QRandomGenerator::global()->bounded(256));
|
||||||
|
return myRandomByte;
|
||||||
|
|
||||||
|
//value.fromValue<bcdata_t>( myRandomByte );
|
||||||
|
|
||||||
TCanMsg msg;
|
TCanMsg msg;
|
||||||
|
|
||||||
uint32_t device = static_cast<uint32_t>(deviceID);
|
uint32_t device = static_cast<uint32_t>(deviceID);
|
||||||
@@ -190,6 +187,7 @@ void BCCanDriverTinyCan::writeRawValue( BCDevice::ID deviceID, BC::ID registerID
|
|||||||
throw BCException( "writeRawValue error: driver not loaded." );
|
throw BCException( "writeRawValue error: driver not loaded." );
|
||||||
|
|
||||||
qDebug() << " --- BCCanDriverTinyCan writeRawValue: " << value;
|
qDebug() << " --- BCCanDriverTinyCan writeRawValue: " << value;
|
||||||
|
return;
|
||||||
|
|
||||||
uint32_t device = static_cast<uint32_t>(deviceID);
|
uint32_t device = static_cast<uint32_t>(deviceID);
|
||||||
uint8_t reg = static_cast<uint8_t> (registerID);
|
uint8_t reg = static_cast<uint8_t> (registerID);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
DriverState initDriver() override;
|
DriverState initDriver() override;
|
||||||
|
|
||||||
bcdata_t readRawValue ( BCDevice::ID deviceID, BC::ID registerID ) const override;
|
bcdata_t readRawValue ( BCDevice::ID deviceID, BC::ID registerID ) const override;
|
||||||
void writeRawValue( BCDevice::ID deviceID, BC::ID registerID, bcdata_t value ) const override;
|
void writeRawValue( BCDevice::ID deviceID, BC::ID registerID, bcdata_t value ) const override;
|
||||||
|
|
||||||
QString getNodeName( unsigned char id );
|
QString getNodeName( unsigned char id );
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QRandomGenerator>
|
|
||||||
|
|
||||||
#include <bcvalue.h>
|
#include <bcvalue.h>
|
||||||
|
|
||||||
@@ -61,9 +61,7 @@ BCValue::BCValue(const BCValueType& valueType_, BCDevice::ID deviceID_, BC::ID r
|
|||||||
|
|
||||||
void BCValue::readRawValue( const BCAbstractTransmitter& transmitter ) const
|
void BCValue::readRawValue( const BCAbstractTransmitter& transmitter ) const
|
||||||
{
|
{
|
||||||
//bcdata_t result = transmitter.readRawValue( deviceID, registerID );
|
|
||||||
bcdata_t myRandomByte = static_cast<quint8>(QRandomGenerator::global()->bounded(256));
|
|
||||||
value.fromValue<bcdata_t>( myRandomByte );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCValue::writeRawValue( const BCAbstractTransmitter& transmitter ) const
|
void BCValue::writeRawValue( const BCAbstractTransmitter& transmitter ) const
|
||||||
|
|||||||
@@ -156,11 +156,12 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((err = CanReceive(0, &msg, 1)) > 0)
|
if ((err = CanReceive(0, &msg, 1)) > 0)
|
||||||
{
|
{
|
||||||
if (--retry && (msg.Id != BIB || msg.MsgLen != 4 || msg.MsgData[1] != reg))
|
if (--retry && (msg.Id != BIB || msg.MsgLen != 4 || msg.MsgData[1] != reg))
|
||||||
goto retry;
|
goto retry;
|
||||||
|
|
||||||
if (!retry) {
|
if (!retry)
|
||||||
|
{
|
||||||
printf("error: no response from node %s to %s" _NL, getNodeName(receipient), getNodeName(BIB));
|
printf("error: no response from node %s to %s" _NL, getNodeName(receipient), getNodeName(BIB));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,42 @@ QPushButton:pressed
|
|||||||
background-color: #005a9e;
|
background-color: #005a9e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Normal */
|
||||||
|
QToolButton {
|
||||||
|
background-color: transparent;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hover */
|
||||||
|
QToolButton:hover {
|
||||||
|
background-color: #E3F2FD;
|
||||||
|
border: 1px solid #2196F3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pressed/Clicked */
|
||||||
|
QToolButton:pressed {
|
||||||
|
background-color: #BBDEFB;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Checked (bei checkable buttons) */
|
||||||
|
QToolButton:checked {
|
||||||
|
background-color: #2196F3;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Checked + Hover */
|
||||||
|
QToolButton:checked:hover {
|
||||||
|
background-color: #1976D2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Disabled */
|
||||||
|
QToolButton:disabled {
|
||||||
|
color: #BDBDBD;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
/* Styling anhand von Objektnamen (ID) */
|
/* Styling anhand von Objektnamen (ID) */
|
||||||
#loginButton
|
#loginButton
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user