Changeset 465

Show
Ignore:
Timestamp:
09/07/09 12:43:48 (15 years ago)
Author:
bhilburn
Message:

First step in revamping component architecture in preperation for fixing
the CBR implementation. Files only now include the declaration for the
component they need - not all of them.

Location:
vtcross/trunk/src
Files:
4 added
14 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/cognitive_engines/CBR_CE/CognitiveEngine.cpp

    r418 r465  
    2020#include <math.h> 
    2121 
     22#include "vtcross/cognitive_engine.h" 
    2223#include "vtcross/common.h" 
    23 #include "vtcross/components.h" 
    2424#include "vtcross/containers.h" 
    2525#include "vtcross/debug.h" 
  • vtcross/trunk/src/cognitive_engines/CBR_CE/cbr_demo.cpp

    r411 r465  
    2727#include <stdint.h> 
    2828 
     29#include "vtcross/cognitive_engine.h" 
    2930#include "vtcross/common.h" 
    30 #include "vtcross/components.h" 
    3131#include "vtcross/containers.h" 
    3232#include "vtcross/debug.h" 
  • vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp

    r411 r465  
    2020#include <math.h> 
    2121 
     22#include "vtcross/cognitive_engine.h" 
    2223#include "vtcross/common.h" 
    2324#include "vtcross/components.h" 
  • vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_Demo.cpp

    r411 r465  
    2727#include <stdint.h> 
    2828 
     29#include "vtcross/cognitive_engine.h" 
    2930#include "vtcross/common.h" 
    30 #include "vtcross/components.h" 
    3131#include "vtcross/containers.h" 
    3232#include "vtcross/debug.h" 
  • vtcross/trunk/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_CE.cpp

    r458 r465  
    1414#include <math.h> 
    1515 
     16#include "vtcross/cognitive_engine.h" 
    1617#include "vtcross/common.h" 
    17 #include "vtcross/components.h" 
    1818#include "vtcross/containers.h" 
    1919#include "vtcross/debug.h" 
  • vtcross/trunk/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_Demo.cpp

    r417 r465  
    1717#include <stdint.h> 
    1818 
     19#include "vtcross/cognitive_engine.h" 
    1920#include "vtcross/common.h" 
    20 #include "vtcross/components.h" 
    2121#include "vtcross/containers.h" 
    2222#include "vtcross/debug.h" 
  • vtcross/trunk/src/include/vtcross/Makefile.am

    r411 r465  
    1616 
    1717include_HEADERS = error.h debug.h socketcomm.h cbr.h components.h \ 
    18                                   containers.h libvtcross.h common.h config.h 
     18                                  containers.h libvtcross.h common.h config.h \ 
     19                                  cross_shell.h service_management_layer.h \ 
     20                                  cognitive_engine.h policy_engine.h 
    1921 
  • vtcross/trunk/src/include/vtcross/components.h

    r461 r465  
    1515*/ 
    1616 
    17 /* This header exports the declarations for all VT-CROSS radio components.  It 
    18  * contains two pure abstract base classes, Component and Engine; Engine derives 
     17/* This header exports the base declarations for all VT-CROSS radio components. 
     18 * It contains two pure abstract base classes, Component and Engine; Engine derives 
    1919 * from Component.  All functions contained within the abstract base classes are 
    2020 * dynamically linked and pure, and all child non-abstract classes derive using  
     
    2323 * implementations, (2) So that symbolic debuggers can navigate the call tree  
    2424 * for typecasted objects of derivative classes. 
     25 * 
     26 * Note that any new component type declaration MUST include this header and 
     27 * extend a parent component type. 
    2528 */ 
    2629 
     
    110113}; 
    111114 
    112  
    113 /* Service Management Layer (SML) class declaration.  The functions listed here 
    114  * are required by the VTCROSS API for service-oriented VTCROSS radio 
    115  * architectures. 
    116  */ 
    117 class ServiceManagementLayer : public Component 
    118 { 
    119     public: 
    120         ServiceManagementLayer(); 
    121         ~ServiceManagementLayer(); 
    122  
    123         /* Overloaded constructor that creates an SML and connects it to the 
    124          * shell with the passed hostname and port. 
    125          */ 
    126         ServiceManagementLayer(const char* SML_Config, const char* serverName, \ 
    127                 const char* serverPort, int16_t clientPort); 
    128  
    129         /* Connect and register with the shell component at the passed hostname 
    130          * and port. 
    131          */ 
    132         void ConnectToShell(const char* serverName, const char* serverPort); 
    133         void SendComponentType(); 
    134         void MessageHandler(int32_t ID); 
    135         void Shutdown(); 
    136         void Reset(); 
    137         void RegisterComponent(); 
    138         void DeregisterComponent(); 
    139  
    140         /* Starts the SML Server and watches it for incoming messages 
    141          */ 
    142         void StartSMLServer(); 
    143  
    144     private:  
    145         /* Receive the radio configuration settings from the shell and pass them 
    146          * on to another component. 
    147          */ 
    148         void TransferRadioConfiguration(int32_t ID); 
    149  
    150         /* Receive information regarding a completed 'experience' and pass it on 
    151          * to the appropriate cognitive engine. 
    152          */ 
    153         void TransferExperience(int32_t ID); 
    154          
    155         /* Listen for other components registering their available services with 
    156          * the SML.  
    157          */ 
    158         void ReceiveServices(int32_t ID); 
    159         void DeregisterServices(int32_t ID); 
    160  
    161         /* Change the active mission of the radio to a new one and adjust radio 
    162          * behavoir appropriately. 
    163          */ 
    164         void SetActiveMission(); 
    165  
    166         /* TODO 
    167          */ 
    168         void RegisterCognitiveEngine(int32_t ID); 
    169         void DeregisterCognitiveEngine(int32_t ID); 
    170  
    171         /* List all services provided to the radio by registered components. 
    172          */ 
    173         void ListServices(); 
    174  
    175         /* Load/Relead the XML configuration file.  
    176          */ 
    177         void ReloadConfiguration(); 
    178         void LoadConfiguration(const char *SML_Config, Mission* &mList); 
    179  
    180         /* Create and initialize the DB to hold the services 
    181         */ 
    182         void CreateServicesDB(); 
    183         void CreateDataDB(); 
    184  
    185         /* TODO 
    186          */ 
    187         void PerformActiveMission(); 
    188         void TransactData(int32_t sourceID); 
    189  
    190         /* The socket file descriptor information for the shell which this SML 
    191          * is connected to. 
    192          */ 
    193         int32_t shellSocketFD; 
    194  
    195         /* TODO 
    196          */ 
    197         int16_t CEPort; 
    198         int16_t SMLport; 
    199  
    200         uint32_t numberOfCognitiveEngines; 
    201  
    202         int32_t cogEngSrv; 
    203         int32_t activeMission; 
    204  
    205         uint32_t Current_ID;  
    206  
    207         bool CE_Present; 
    208         CE_Reg *CE_List; 
    209         Mission *miss; 
    210 }; 
    211  
    212  
    213 /* Policy Engine class declaration.  All public functions are inherited from 
    214  * parent classes. 
    215  */ 
    216 class PolicyEngine : public Engine 
    217 { 
    218     public: 
    219         PolicyEngine(); 
    220         ~PolicyEngine(); 
    221  
    222         /* Overloaded constructor that creates a policy engine object and 
    223          * connects it to either the shell or an SML, depening on the SML bool. 
    224          */ 
    225         PolicyEngine(const char* serverName, const char* serverPort, \ 
    226                 const bool SML); 
    227  
    228         void SendComponentType(); 
    229         void ConnectToRemoteComponent(const char* serverName, \ 
    230                 const char* serverPort, const bool SML); 
    231         void WaitForSignal(); 
    232         void Shutdown(); 
    233         void Reset(); 
    234         void RegisterComponent(); 
    235         void DeregisterComponent(); 
    236  
    237         void RegisterServices(); 
    238         void DeregisterServices(); 
    239  
    240     private: 
    241         /* Parse and load/reload policies into the policy engine. 
    242          */ 
    243         void LoadPolicies(); 
    244         void ReloadPolicies(); 
    245  
    246         /* Return a decision made by the policy engine regarding a certain set 
    247          * of transmission parameters. 
    248          */ 
    249         void SendPEDecision(struct Parameter pList[], struct Radio_Info *radio_info, \ 
    250                 int32_t decision_array[]); 
    251  
    252         /* Validate a set of transmission parameters received from the radio. 
    253          */ 
    254         void ValidateParameters(); 
    255  
    256         /* The SML_present bool reflects whether or not the remote component 
    257          * this object is connected to is an SML.  If it isn't, then it must be 
    258          * a shell.  The socketFD stores the socket file descriptor for this 
    259          * connection. 
    260          */ 
    261         bool SML_present; 
    262         int32_t commandSocketFD; 
    263 }; 
    264  
    265  
    266 /* Cognitive Engine class declaration.  All public functions are inherited from 
    267  * parent classes. 
    268  */ 
    269 class CognitiveEngine : public Engine 
    270 { 
    271     public: 
    272         CognitiveEngine(); 
    273         ~CognitiveEngine(); 
    274  
    275         /* Overloaded constructor that creates a cognitive engine object and 
    276          * connects it to either the shell or an SML, depening on the SML bool. 
    277          */ 
    278         CognitiveEngine(const char* serverName, const char* serverPort, \ 
    279                 const bool SML); 
    280          
    281         void SendComponentType(); 
    282         void ConnectToRemoteComponent(const char* serverName, \ 
    283                 const char* serverPort, const bool SML); 
    284         void WaitForSignal(); 
    285         void Shutdown(); 
    286         void Reset(); 
    287         void RegisterComponent(); 
    288         void DeregisterComponent(); 
    289  
    290         void RegisterServices(); 
    291         void DeregisterServices(); 
    292  
    293     private: 
    294         /* Receive the transmitted radio configuration from the radio itself 
    295          * (the CE will not always be local to the radio). 
    296          */ 
    297         void ReceiveRadioConfiguration(); 
    298  
    299         /* Receive an 'experience' report from the radio. 
    300          */ 
    301         void ReceiveExperience(); 
    302  
    303         /* Find the most optimal set of transmission parameters given certain 
    304          * observables and possibly a service if the SML component is present 
    305          * and active. 
    306          */ 
    307         Parameter *GetSolution(Observable *observables, Parameter *currentParameters); 
    308         Parameter *GetSolution(Observable *observables, Parameter *currentParameters, \ 
    309                 std::string service); 
    310  
    311         /* Receive a feedback from the radio regarding the performance of a 
    312          * certain set of parameters, possibly associated with a service. 
    313          * 
    314          * Feedback is a single set of performance statistics that is achieved 
    315          * corresponding to a specific set of transmission parameters.  Feedback 
    316          * helps a Cognitive Engine make better future decisions based upon  
    317          * more accurate performance statistics.  
    318          */ 
    319         void ReceiveFeedback(Observable *observables,\ 
    320                 Parameter *parameters); 
    321         void ReceiveFeedback(Observable *observables, \ 
    322                 Parameter *parameters, std::string service); 
    323  
    324  
    325         /* BuildCognitiveEngine performs the CE implementation specific work 
    326          * that defines the internals of a CE.  For example, a CBR CE engine 
    327          * would build the case-base reasoner or create the database, a neural 
    328          * network based CE may perform the initial training, a GA based CE 
    329          * may build the chromosome structure. 
    330          */ 
    331         void BuildCognitiveEngine(); 
    332  
    333         /* The SML_present bool reflects whether or not the remote component 
    334          * this object is connected to is an SML.  If it isn't, then it must be 
    335          * a shell.  The socketFD stores the socket file descriptor for this 
    336          * connection. 
    337          */ 
    338         bool SML_present; 
    339         int32_t commandSocketFD; 
    340          
    341         // TODO Need a description for these fields.  Are these radio utilites, 
    342         // parameters, and observables global to the whole system? 
    343         Utility *uList; 
    344         Parameter *pList; 
    345         Observable *oList; 
    346         struct Radio_Info *radioInfo; 
    347 }; 
    348  
    349 /* Cognitive Radio Shell class declaration.  
    350  */ 
    351 class CognitiveRadioShell  
    352 { 
    353     public: 
    354         CognitiveRadioShell(); 
    355         ~CognitiveRadioShell(); 
    356  
    357         /* Overloaded constructor that creates a CR Shell object and loads the 
    358          * passed radio configuration XML file. 
    359          */ 
    360         CognitiveRadioShell(const char* radioConfig, int16_t primaryPort, \ 
    361             int16_t policyPort, int16_t commandPort); 
    362  
    363         /* Ask for the component type of a remote component via sockets, or 
    364          * respond to such a query sent to the shell itself. 
    365          */ 
    366         std::string GetRemoteComponentType(int32_t socketFD); 
    367         void SendComponentType(int32_t socketFD); 
    368  
    369         void Shutdown(); 
    370         void Reset(); 
    371          
    372         /* Start all the socket servers */ 
    373         void StartShellServer();  
    374  
    375         int32_t LoadRadioConfiguration(const char* radioConfig, Parameter* &pList, \ 
    376             Utility* &uList, Observable* &oList, Radio_Info* radioInfo); 
    377     private: 
    378         /* Parse and load/reload policies into the policy engine. 
    379          */ 
    380         void LoadPolicies(); 
    381         void ReloadPolicies(); 
    382  
    383         /* Register and Deregister the different components. 
    384          */ 
    385         void RegisterCognitiveEngine(int32_t socketFD); 
    386         void DeregisterCognitiveEngine(int32_t socketFD); 
    387         void RegisterPolicyEngine(int32_t socketFD); 
    388         void DeregisterPolicyEngine(int32_t socketFD); 
    389         void RegisterSML(int32_t socketFD); 
    390         void DeregisterSML(int32_t socketFD); 
    391          
    392         void SetActiveMission(int32_t socketFD); 
    393  
    394         /* Handle a message that is received from a component. 
    395          */ 
    396         int32_t HandleMessage(int32_t socketFD); 
    397         
    398         /* Send optimization request to primary port FD. 
    399          */ 
    400         void GetOptimalParameters(int32_t socketFD); 
    401  
    402         /* TODO 
    403          */ 
    404         bool SendRadioConfiguration(int32_t socketFD); 
    405         bool SendRadioExperience(int32_t socketFD); 
    406  
    407         /* TODO 
    408          */ 
    409         bool UpdateParameterPerformance(int32_t socketFD); 
    410  
    411         /* TODO 
    412          */ 
    413         bool SML_present; 
    414         bool PE_present; 
    415         bool CE_present; 
    416         
    417         /* TODO 
    418          */ 
    419         int32_t numberOfCognitiveEngines;  
    420  
    421         /* TODO 
    422          */        
    423         int16_t primaryPort; 
    424         int16_t policyPort; 
    425         int16_t commandPort; 
    426  
    427         /* TODO 
    428          */ 
    429         int32_t ceSocketFD; 
    430         int32_t commandSocketFD; 
    431         int32_t policySocketFD; 
    432  
    433         /* TODO 
    434          */ 
    435         Utility *utils; 
    436         Parameter *params; 
    437         Observable *observables; 
    438  
    439         /* TODO 
    440          */ 
    441         struct Radio_Info *radio_info; 
    442 }; 
    443  
    444115#endif 
  • vtcross/trunk/src/policy_engines/PolicyEngine.cpp

    r411 r465  
    2424 
    2525#include "vtcross/common.h" 
    26 #include "vtcross/components.h" 
    2726#include "vtcross/containers.h" 
    2827#include "vtcross/debug.h" 
    2928#include "vtcross/error.h" 
     29#include "vtcross/policy_engine.h" 
    3030#include "vtcross/socketcomm.h" 
    3131 
  • vtcross/trunk/src/policy_engines/policy_demo.cpp

    r411 r465  
    2828 
    2929#include "vtcross/common.h" 
    30 #include "vtcross/components.h" 
    3130#include "vtcross/containers.h" 
    3231#include "vtcross/debug.h" 
    3332#include "vtcross/error.h" 
     33#include "vtcross/policy_engine.h" 
    3434#include "vtcross/socketcomm.h" 
    3535 
  • vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp

    r461 r465  
    5252#include "vtcross/error.h" 
    5353#include "vtcross/common.h" 
    54 #include "vtcross/components.h" 
    5554#include "vtcross/containers.h" 
     55#include "vtcross/service_management_layer.h" 
    5656#include "vtcross/socketcomm.h" 
    5757 
  • vtcross/trunk/src/service_management_layer/sml_demo.cpp

    r411 r465  
    3434#include "sqlite3.h" 
    3535 
    36 //#include "tinyxml.h" 
    37 //#include "tinyxml.cpp" 
    38 //#include "tinystr.h" 
    39  
    4036#include "vtcross/common.h" 
    41 #include "vtcross/components.h" 
    4237#include "vtcross/containers.h" 
    4338#include "vtcross/debug.h" 
    4439#include "vtcross/error.h" 
     40#include "vtcross/service_management_layer.h" 
    4541#include "vtcross/socketcomm.h" 
    46  
    47  
    48  
    49 /*#include <stdio.h> 
    50 #include <sys/types.h> 
    51 #include <sys/socket.h> 
    52 #include <netinet/in.h> 
    53 #include <netdb.h> 
    54 //#include <iostream> 
    55 #include <stdlib.h> 
    56 #include <string.h> 
    57 #include <sqlite3.h> 
    58 #include <sqlite3ext.h>*/ 
    59  
    60 //#include "common.h" 
    61  
    62 //using namespace std; 
    6342 
    6443 
  • vtcross/trunk/src/shell/CognitiveRadioShell.cpp

    r437 r465  
    3939 
    4040#include "vtcross/common.h" 
    41 #include "vtcross/components.h" 
    4241#include "vtcross/containers.h" 
     42#include "vtcross/cross_shell.h" 
    4343#include "vtcross/debug.h" 
    4444#include "vtcross/error.h" 
  • vtcross/trunk/src/shell/shell_demo.cpp

    r411 r465  
    2323 
    2424#include "vtcross/common.h" 
    25 #include "vtcross/components.h" 
     25#include "vtcross/cross_shell.h" 
    2626#include "vtcross/error.h" 
    2727