Initial commit of files
This commit is contained in:
116
include/libcan++/CanSignal.h
Normal file
116
include/libcan++/CanSignal.h
Normal file
@ -0,0 +1,116 @@
|
||||
//****************************************************************************
|
||||
// Copyright (C) 2007
|
||||
// Nissan North America
|
||||
// All Rights Reserved. Proprietary and Confidential.
|
||||
//============================================================================
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __CanSignal__
|
||||
#define __CanSignal__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
//#include "BaseSignal.h"
|
||||
//#include "VoltType.h"
|
||||
|
||||
#include "CanSocket.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
// based on .dbc data
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
//
|
||||
// Uses the Peak Systems CAN Linux driver and Nissan CAN data
|
||||
//
|
||||
#ifdef __BaseSignal__
|
||||
class CanSignal : public BaseSignal, public VoltType {
|
||||
#else
|
||||
class CanSignal {
|
||||
#endif
|
||||
// public data
|
||||
public:
|
||||
std::string Name; // Signal Name
|
||||
std::string Units; // Signal Units
|
||||
u_int32_t Address; // 29 bits (standard or extended)
|
||||
|
||||
// data conversion (from .dbc file)
|
||||
u_char StartBit; // 0..63
|
||||
u_char NumBits; // 1..32
|
||||
u_char BigEndian; // 0 = little endian (intel), 1 = big endian (moto)
|
||||
u_char IsSigned; // 0 = unsigned, 1 = 2's Complement
|
||||
double Scale; // scale
|
||||
double Offset; // offset
|
||||
|
||||
// conversion help
|
||||
u_char StartByte; // 0..7
|
||||
u_char NumBytes; // 1..4
|
||||
u_char HighBit; // 0..7
|
||||
u_char LowBit; // #bits after
|
||||
u_int64_t Mask; // 64 bit mask
|
||||
u_int64_t Sign; // 64 bit sign mask
|
||||
|
||||
// status, data
|
||||
u_char doSubscribe; // CanSocket filter
|
||||
u_char isNew;
|
||||
u_char isValid;
|
||||
int32_t rawValue;
|
||||
int64_t currValue;
|
||||
int64_t lastValue;
|
||||
double realValue;
|
||||
|
||||
// misc
|
||||
u_int64_t activity; // activity counter
|
||||
void *userData; // user data
|
||||
int userIndex; // user index
|
||||
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
CanSignal();
|
||||
|
||||
// destructor
|
||||
virtual ~CanSignal();
|
||||
|
||||
// virtual functions
|
||||
|
||||
// public methods
|
||||
int Init( void );
|
||||
int Convert(CanFrame *frame) {return Read(frame->data);};
|
||||
int Read(CanFrame *frame) {return Read(frame->data);};
|
||||
int Read(const u_char *pbyData, long *ldata=NULL, double *ddata=NULL);
|
||||
int Write(CanFrame *frame) {return Write(frame->data);};
|
||||
int Write(u_char *pbyData);
|
||||
int Write(long value, u_char *pbyData);
|
||||
long Write(double value, u_char *pbyData);
|
||||
void Subscribe(void) {doSubscribe=1;};
|
||||
void Unsubscribe(void) {doSubscribe=0;};
|
||||
|
||||
#ifndef __VoltType__
|
||||
void SetScaling( double scale=1.0, double offset=0.0 ) { Scale=scale; Offset=offset; };
|
||||
double GetScale( void ) { return Scale; };
|
||||
double GetOffset( void ) { return Offset; };
|
||||
#endif
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user