Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

ControlBlock.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // ControlBlock.cpp 00005 // 00006 // Version 1.0 00007 // Date 11.04.03 (Version 1.0) 00008 // Author A. Pasetti (P&P Software), R. Totaro 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/DebugSupport.h" 00012 #include "../GeneralInclude/BasicTypes.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "../Base/CC_RootObject.h" 00015 #include "ControlBlock.h" 00016 00017 ControlBlock::ControlBlock(void) { 00018 x =pNULL; 00019 p =pNULL; 00020 nInputs =-1; 00021 nOutputs =-1; 00022 nStates =-1; 00023 nParameters=-1; 00024 } 00025 00026 void ControlBlock::setNumberOfStates(unsigned int n) { 00027 assert(nStates<0); 00028 00029 nStates=n; 00030 x=new TD_Float[n]; 00031 for (unsigned int i=0;i<n;i++) 00032 x[i]=(TD_Float)0.0; 00033 } 00034 00035 void ControlBlock::setNumberOfParameters(unsigned int n) { 00036 assert(nParameters<0); 00037 00038 nParameters=n; 00039 p=new TD_Float[n]; 00040 for (unsigned int i=0;i<n;i++) 00041 p[i]=(TD_Float)0.0; 00042 } 00043 00044 void ControlBlock::setState(unsigned int i,TD_Float newValue) { 00045 assert(x!=pNULL && (int)i<nStates); 00046 00047 if ((int)i<nStates) 00048 x[i]=newValue; 00049 else 00050 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_CB); 00051 } 00052 00053 void ControlBlock::setParameter(unsigned int i,TD_Float newValue) { 00054 assert(p!=pNULL && (int)i<nParameters); 00055 00056 if ((int)i<nParameters) 00057 p[i]=newValue; 00058 else 00059 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_CB); 00060 } 00061 00062 void ControlBlock::propagate(void) { 00063 assert(isObjectConfigured()); 00064 00065 propagateState(); 00066 updateOutput(); 00067 } 00068 00069 void ControlBlock::reset(void) { 00070 assert(x!=pNULL); 00071 00072 for (int i=0;i<nStates;i++) 00073 x[i]=(TD_Float)0.0; 00074 } 00075 00076 bool ControlBlock::isObjectConfigured(void) { 00077 return (CC_RootObject::isObjectConfigured() && 00078 nInputs!=-1 && nOutputs!=-1 && nStates!=-1 && nParameters!=-1); 00079 } 00080
Copyright 2003 P&P Software GmbH - All Rights Reserved