00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef TAC_STDBLOCK_H
00012 #define TAC_STDBLOCK_H
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "tacTypes.h"
00032 #include "tacDefines.h"
00033 #include "tacErrors.h"
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 typedef struct {
00044 char typeName[tacMAX_NAME_SIZE];
00045 tacFCTPTR typeConstructorHook;
00046 tacFCTPTR typeGetParameterHook;
00047 tacVOIDFCTPTR typeAlgorithmHook;
00048 tacFCTPTR typeSetParameterHook;
00049 tacVOIDFCTPTR typeResetHook;
00050 tacVOIDFCTPTR typeStopHook;
00051 tacVOIDFCTPTR typeDestructorHook;
00052 tacVOIDFCTPTR typeShowHook;
00053 }tacSTDBLOCK_TYPE;
00054
00055 typedef tacPARAM tacSTDBLOCK_PARAM;
00056
00057 typedef struct {
00058 unsigned short type;
00059 char name[tacMAX_NAME_SIZE];
00060 unsigned short resolved;
00061 void (* algorithm)();
00062 void* parameter;
00063 double** input;
00064 double* output;
00065 tacSHARED* shared;
00066 }tacSTDBLOCK;
00067
00068
00069
00070
00071
00072 #define tacStdBlockGetSamplingPeriod(pSelf) ((*pSelf->shared).samplingPeriod)
00073 #define tacStdBlockGetTime(pSelf) (&((*pSelf->shared).currentTime))
00074 #define tacStdBlockGetSimulation(pSelf) ((*pSelf->shared).simulation)
00075 #define tacStdBlockGetInput(pSelf,inputIndex) (*(pSelf->input[inputIndex]))
00076 #define tacStdBlockGetOutput(pSelf,outputIndex) (pSelf->output[outputIndex])
00077 #define tacStdBlockSetOutput(pSelf,outputIndex,value) \
00078 { \
00079 pSelf->output[outputIndex] = value; \
00080 }
00081 #define tacStdBlockSetAlgorithm(pSelf,pAlgo) \
00082 { \
00083 pSelf->algorithm = pAlgo; \
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 STATUS tacStdBlockInitAll(void);
00095 STATUS tacStdBlockInstallNewType(tacSTDBLOCK_TYPE* typeInfo);
00096
00097 STATUS tacStdBlockConstructor(tacSTDBLOCK** pSelf, char* type, char* name, tacSTDBLOCK_PARAM* parameter,
00098 tacSHARED* shared, tacERROR* error);
00099 STATUS tacStdBlockReport(tacSTDBLOCK* pSelf, char* type, char* name, tacSTDBLOCK_PARAM* parameter, tacERROR* error);
00100 STATUS tacStdBlockSetParameter(tacSTDBLOCK* pSelf, tacSTDBLOCK_PARAM* parameter, tacERROR* error);
00101
00102 void tacStdBlockReset(tacSTDBLOCK* pSelf);
00103 void tacStdBlockStop(tacSTDBLOCK* pSelf);
00104 void tacStdBlockDestructor(tacSTDBLOCK* pSelf);
00105
00106 double* tacStdBlockGetOutputRef(tacSTDBLOCK* pSelf, unsigned short outputPort);
00107
00108 void tacStdBlockSetInputNumber(tacSTDBLOCK* pSelf, unsigned short inputNumber);
00109 int tacStdBlockIsResolved(tacSTDBLOCK* pSelf);
00110
00111 STATUS tacStdBlockAttachInput(tacSTDBLOCK* pSelf, unsigned short inputPort, double* signal, tacERROR* error);
00112 STATUS tacStdBlockDetachInput(tacSTDBLOCK* pSelf, unsigned short inputPort, tacERROR* error);
00113
00114
00115
00116
00117
00118 STATUS tacStdBlockAllocateArrays(tacSTDBLOCK* pSelf,
00119 unsigned short paramNb,
00120 unsigned short inputNb,
00121 unsigned short outputNb,
00122 tacERROR* error);
00123
00124 #endif