📄 config.h
字号:
#ifndef __CONFIGH__ /* Schutz gegen mehrfaches #include */
#define __CONFIGH__
/***********************************************************************
* config.h
* Projekt : UCIO
* Funktion: Headerdatei fuer das Softwaremodul "config.c".
* Definiert die Datenstrukturen, in denen zur Laufzeit die Message-
* und Datenobjekte beschreiben werden.
*
* Autor : Hoppe
* Sprache : Keil-C51
*
* ----------------------------------------------------------------
* Copyright (C) 1998 by J. Hoppe
* */
#include "compiler.h"
#include "ppcanc.h"
#include "funcblks.h" // Definitionen von Init()/Calc()/Free()
/*** Konstantendefinitionen ***/
#define MAX_LISTMESSAGES 12 /* max. soviele Sensor/Aktormsgs. sind moegl. */ // Hardi 18.10.99: changed from 20 to 25
// 18.07.00: changed to 35
#define MAX_DATAOBJS 24 /* max. " Datenobjekte & default values */ // Hardi 18.10.99: changed from 100 to 150
#define MAX_DO2MSGS 24 /* max. " Verknuepfungen DO - Message */
#define MAX_MSGDATAOBJS 10 /* max. " Datenobjekte pro Message */
#define MAX_DATAOBJMSGS 3 /* max. " Messages pro Datenobjekt */
#define MAX_DATAOBJLIMITS 3 /* max. " Limits pro Datenobjekt */
#define MAX_DEFAULTVALS 12 /* max. " Defaults */
#define MAX_VALLIMITS 12 /* max. " Wertebereiche */ // Hardi VL 04.10.99: changed from 10 to 20
#define MAX_SPAREVALS 0 /* max. " freie Parameter */
#define MAX_FUNCBLOCKS 6 /* max. " Algorithmen */
#define MAX_EVENTS 5 /* max. " Event based messagings */
#define MAX_TIMEEVENTS 2 /* max. " Time Events */
#define MAX_CURVES 0 /* max. " Kennlinien */
// Overrange/underrange Flags
#define VALSTATE_UNDER 0 // must fit in 3 bits!
#define VALSTATE_NORMAL 1
#define VALSTATE_OVER 2
#define VALSTATE_OUTSIDE 3
#define VALSTATE_UNKNOWN 7
// Hardi VL 30.09.99: New
#define VL_UpError 0x10 // The states of a value.
#define VL_UpLimit 4 // The each number representes a bit. They are sorted
#define VL_Normal 1 // in a way that the Errors have a higer value than the limits.
#define VL_LoLimit 2 // This is usefull to shift out the unimportant bits.
#define VL_LoError 8
/* Errorcodes fuer Listen */
#define LISTCODE_MSGLIST 1
#define LISTCODE_DOLIST 2
#define LISTCODE_DO2MSGLIST 3
#define LISTCODE_DEFAULTLIST 4
#define LISTCODE_LIMITLIST 5
#define LISTCODE_SPARELIST 6
#define LISTCODE_FUNCBLOCKLIST 7
#define LISTCODE_CURVELIST 8
#define LISTCODE_EVENTLIST 9
#define LISTCODE_TIMEEVENTLIST 10
/*** Typendefinitionen ***/
/* Beschreibung eines Datenobjects */
typedef struct _TDataObj
{
uchar iofunc ; /* Typ des IO-Pins und Grundbearbeitungsfunktion */
uword ionr ; /* Nr des Pins / Modultyp und Functionsnr. */
long val ;
struct _TDefaultVal *defaultptr ; // Ptr auf Defaultwert, falls da
// struct _TSpareVals *spareptr ; // Ptr auf freie Parms, falls da
/* Zeigerliste auf Messages, die dieses DO beinhalten (Ende mit NULL) */
struct _TDO2Msg *d2ms[MAX_DATAOBJMSGS+1] ;
/* Zeiger auf relevante Wertelimits */
struct _TValLimits *vallimits ;
uchar valstate ;
// Datatobj hat keinen gueltigen Wert,
// sondern ist VALSTATE_UNDER/OVER/OUTSIDE/NORMAL.
// Wird gesetzt, wenn Vallimits verletzt sind und in den Aktionen der
// Vallimits ACTION_RANGEERROR_OVERUNDERSIGNAL | ACTION_RANGEERROR_SIMPLESIGNAL
// gesetzt ist.
} TDataObj ;
/* Beschreibung einer aktive Message(Sensor oder Actor) */
typedef struct _TMessage
{
uchar BusID ; /* zug. CAN-Bus */
uword MsgID ;
uword period ; /* Sende- oder Abfrageperiode, sollperiode fuer Empfang */
uchar is_sensor ; /* 1 = ist Sensormessage */
uchar rtr ; /* 1 == remote-request ist erlaubt */
uchar len ; /* berechnete Laenge der Msg */
ulong nextperiodictime ; /* naechster periodischer Sende- bzw. Empfangs-Timeout-Zeitpunkt */
/* Zeigerliste auf IO-Objecte der Message (Ende mit NULL) */
struct _TDO2Msg *d2ms[MAX_MSGDATAOBJS+1] ;
/* 1, wenn ActorMessage timeout hatte */
uchar timed_out ;
uword eventperiod ; /* haeufiger wird die Msg nie on "event" gesendet */
// ist gleichzeitig die event-compare rate
uchar onevent ; /* eines der msg->d2m[] hat "ev" gesetzt */
ulong nexteventtime ; /* naechster Event-Check-Zeitpunkt */
} TMessage ;
/* Beschreibung der Darstellung eines Datenobjects in einer Message */
typedef struct _TDO2Msg
{
struct _TDataObj *dataobj ; /* Zeiger auf das Datenobjekt */
struct _TMessage *msg ; /* Zeiger auf die Message */
struct _TEvent *ev ; // Zeiger auf Event dieses DO/MSG
long scale ; /* Multiplikator */
long offset ; /* Additionswert */
uchar bitlen ;
uchar bitpos ;
uchar bytepos ;
uchar signedval ;
uchar motfmt ;
/* abgeleitete Werte */
uchar calc ; /* Umrechnung mit scale/offset machen */
uchar bitinv ; /* Umrechnung mit scale/offset machen */
long last_sent_rawval ; // zuletzt auf den Bus gegebener Wert
// (ohne scale/offset)
} TDO2Msg ;
/* Beschreibung eines Defaultwertes fuer ein DO */
typedef struct _TDefaultVal {
uchar iofunc ; /* Kennung des DO */
uchar ionr ;
long defaultval ;
} TDefaultVal ;
typedef struct _TValLimits {
// Info aus PPCAN-Record Dienst 5
uchar iofunc ; // Kennung des zugehoerigen Datenobjects
uchar ionr ;
TDataObj *dataobj ; // Zeiger auf zugeh. Datenobjekt
long LoError; // untere Grenze (in Sensor-Rohdarstellung!)
long UpError; // obere Grenze
long ErrorTime; // Zeit, bis Ueberschreitung erkannt wird, in ms
long LoLimit; // untere Grenze (in Sensor-Rohdarstellung!)
long UpLimit; // obere Grenze
long LimitTime; // Zeit, bis Ueberschreitung erkannt wird, in ms
uword action; // describes the type of aktion (bit mask)
uchar FlagMask; // Bit mask that selects the state which will be copied to the following IOFn/IONo
uchar FlagIOFn;
uchar FlagIONo;
// Zeiger auf Flag-Datenobjekte
struct _TDataObj *dataobj_Flag; // ToDo: Wozu braucht man das ??
int old_class;
int class;
ulong wait;
} TValLimits ;
/* Beschreibung eines Satzes von freien Parametern fuer ein DO */
typedef struct _TSpareVals {
uchar iofunc ; /* Kennung des DO */
uchar ionr ;
long spareval[4];
} TSpareVals ;
typedef struct _TFuncBlock {
uword Functioncode ;
uchar Input1IOFunc ; /* Kennung des Input1-DO */
uchar Input1IONr ;
uchar Input2IOFunc ; /* Kennung des Input1-DO */
uchar Input2IONr ;
uchar OutputIOFunc ; /* Kennung des Input1-DO */
uchar OutputIONr ;
long Param[6];
uword CycleTime ;
ulong nextperiodictime;
uchar active;
/* Zeiger auf I/O */
struct _TDataObj *input1 ; /* not used */
struct _TDataObj *input2 ; /* not used */
struct _TDataObj *output ; /* not used */
/* Zeiger auf Methoden */
TFuncBlockMallocProc mallocproc;
TFuncBlockInitProc initproc ;
TFuncBlockResetProc resetproc ;
TFuncBlockCalcFunc calcfunc ;
TFuncBlockFreeProc freeproc ;
uchar inputs ; /* Anzahl von Inputkanaelen */
uchar usedpar;
void *bufptr ; /* Zeiger auf allokierten memory */
uchar changed;
} TFuncBlock ;
/* Beschreibung eines Events */
typedef struct _TEvent {
unsigned char BusID ; /* Kopplung an Dienst 2 record */
unsigned short MsgID ;
unsigned char IOFunc ;
unsigned char IONr ;
signed char EventType ; // Trigger mode
long int Threshold ;
struct _TDO2Msg *d2m ; // Verweis auf Datenobjekt. NULL: Event invalid
long int raw_threshold ; //
} TEvent ;
// Description of a Time Event
typedef struct _TimeEvent
{
unsigned char IOFunc ; // verwendeter IO-Pin: Art und Funktion
unsigned char IONr ; // verw. IO-Pin: lfd. Nr. in einer Funktionsgruppe
long int Value; // The value that takes efect after the trigger time
unsigned int Type; // Describes the type of the time event
long int TriggerTime;// Trigger time when the value is set (signed because its defined so in PPCANCfg)
long int Param1; // Free parameter 1
long int Param2; // Free parameter 1
} TimeEvent;
/* Beschreibung einer Kennlinie */
typedef struct _TCurve {
uchar curveid ; /** Kennung der Kurve */
uchar pointcount ;
TCurvePoint point[31] ; /* max. 31 Punkte.
// genau wie in PCPAN_record (memcpy)! TCurvePoint s. ppcan.h */
} TCurve ;
/*** Deklaration von Objekten fuer andere Module ***/
#ifndef __MESSAGESC__
extern TMessage * ActorMessages[MAX_LISTMESSAGES+1] ;
extern TMessage * SensorMessages[MAX_LISTMESSAGES+1] ;
extern TDataObj * DataObjects[MAX_DATAOBJS+1] ;
extern TDO2Msg * DO2Msgs[MAX_DO2MSGS+1] ;
extern TValLimits * ValLimits[MAX_VALLIMITS+1] ;
extern TDefaultVal * DefaultVals[MAX_DEFAULTVALS+1] ;
//extern TSpareVals * SpareVals[MAX_SPAREVALS+1] ;
extern TFuncBlock * FuncBlocks[MAX_FUNCBLOCKS+1] ;
extern uword FuncBlockCount ; // Zaehler wird gebraucht.
//extern TEvent * Events[MAX_EVENTS+1] ;
//extern TimeEvent * TimeEvents[MAX_TIMEEVENTS+1]; // Hardi 11.11.99:
//extern TCurve * Curves[MAX_CURVES+1] ;
//extern uword CurvesCount ;
/* Config-Info */
extern uchar ConfigNr ;
extern uchar ConfigVersionMain ;
extern uchar ConfigVersionSub ;
extern char ConfigFileName[40+1] ;
extern uchar ConfigFileYear ;
extern uchar ConfigFileMonth ;
extern uchar ConfigFileDay ;
extern uchar ConfigChecksum ;
extern char ConfigRemark[40+1] ;
#endif /* __MESSAGESC__ */
/*** Prototypen fuer Methoden ***/
void Config_Init(void) ;
void Config_RegisterConfigInfo(TPPCANC_CONFIGINFO *ppcan_rec) ;
uchar Config_RegisterMsg(TPPCANC_MSGCFG *ppcan_rec) ;
uchar Config_RegisterMsgExtension(TPPCANC_MSGCFGX *ppcan_rec) ;
uchar Config_RegisterDataObj(TPPCANC_DATAOBJ *ppcan_rec) ;
uchar Config_RegisterDefault(TPPCANC_DO_DEFAULT *ppcan_rec) ;
uchar Config_RegisterSpare(TPPCANC_DO_SPARE *ppcan_rec) ;
uchar Config_RegisterValLimits(TPPCANC_DO_LIMITS *ppcan_rec) ;
uchar Config_RegisterFuncblock(TPPCANC_FUNCBLOCK *ppcan_rec) ;
uchar Config_RegisterEvent(TPPCANC_EVENTMSGING *ppcan_rec) ;
uchar Config_RegisterTimeEvent(TPPCANC_TIMEEVENT *ppcan_rec);
uchar Config_RegisterCurve(TPPCANC_CURVE *ppcan_rec) ;
uchar Config_SaveOpen(uchar filenr) ;
uchar Config_Save(void) ;
uchar Config_SaveClose(void) ;
uchar Config_LoadOpen(uchar filenr) ;
uchar Config_Load(void) ;
uchar Config_LoadClose(void) ;
void Config_Free(void) ;
TMessage * Config_ID2Msg(TMessage ** mlist, uchar BusID, uword MsgID ) ;
TMessage * Config_DO2Msg(TMessage ** mlist, uchar iofunc, uchar ionr) ;
void IO2DO_clrtable(void) ;
void IO2DO_registerDO(TDataObj *d) ;
TDataObj *IO2DO(uchar iofunc, uchar ionr) ;
void VariableFB_ReInit(TFuncBlock *fb);
#endif /* __CONFIGH__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -