Changeset 203

Show
Ignore:
Timestamp:
03/24/09 18:03:08 (15 years ago)
Author:
bhilburn
Message:

Making ConnectToRemoteComponent? an engine function since the SML doesn't
need it, adding a bool representing presence of SML, updating
PolicyEngine? to reflect changes.

Location:
vtcross/trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/include/vtcross/components.h

    r195 r203  
    5656 
    5757 
     58        /* Wait for a command signal containing task instructions. 
     59         */ 
     60        virtual void WaitForSignal() = 0; 
     61 
     62 
     63        /* Completely shutdown the radio and all operations. 
     64         */ 
     65        virtual void Shutdown() = 0; 
     66 
     67 
     68        /* Reset the radio and reload all configuration files. 
     69         * 
     70         * TODO are we remembering experiences in CEs? 
     71         */ 
     72        virtual void Reset() = 0; 
     73 
     74 
     75        /* Register or deregister a component with the primary radio shell. 
     76         */ 
     77        virtual void RegisterComponent() = 0; 
     78        virtual void DeregisterComponent() = 0; 
     79}; 
     80 
     81 
     82/* Engine abstract base class from which all engine component types should 
     83 * inherit (e.g. cognitive and policy engines). Inherits all functions from the 
     84 * ABC Component publically. 
     85 */ 
     86class Engine : public Component 
     87{ 
     88    public: 
    5889        /* Connect to the remote control component, which will always be either 
    5990         * the VTCROSS shell or SML.  Based on the status of the SML_present 
     
    6495         */ 
    6596        virtual void ConnectToRemoteComponent(const char* serverName, \ 
    66                 const char* serverPort) = 0; 
    67  
    68         /* Wait for a command signal containing task instructions. 
    69          */ 
    70         virtual void WaitForSignal() = 0; 
    71  
    72  
    73         /* Completely shutdown the radio and all operations. 
    74          */ 
    75         virtual void Shutdown() = 0; 
    76  
    77  
    78         /* Reset the radio and reload all configuration files. 
    79          * 
    80          * TODO are we remembering experiences in CEs? 
    81          */ 
    82         virtual void Reset() = 0; 
    83  
    84  
    85         /* Register or deregister a component with the primary radio shell. 
    86          */ 
    87         virtual void RegisterComponent() = 0; 
    88         virtual void DeregisterComponent() = 0; 
    89 }; 
    90  
    91  
    92 /* Engine abstract base class from which all engine component types should 
    93  * inherit (e.g. cognitive and policy engines). Inherits all functions from the 
    94  * ABC Component publically. 
    95  */ 
    96 class Engine : public Component 
    97 { 
    98     public: 
     97                const char* serverPort, const bool SML) = 0; 
     98 
     99 
    99100        /* Register or deregister services that this engine provides with the 
    100101         * service management layer. 
     
    115116        ~ServiceManagementLayer(); 
    116117 
     118        /* Overloaded constructor that creates an SML and connects it to the 
     119         * shell with the passed hostname and port. 
     120         */ 
     121        ServiceManagementLayer(const char* serverName, const char* serverPort); 
     122 
     123        /* Connect and register with the shell component at the passed hostname 
     124         * and port. 
     125         */ 
     126        void ConnectToShell(const char* serverName, \ 
     127                const char* serverPort); 
     128 
    117129        void SendComponentType(); 
    118         void ConnectToRemoteComponent(const char* serverName, \ 
    119                 const char* serverPort); 
    120130        void WaitForSignal(); 
    121131        void Shutdown(); 
     
    185195        void SendComponentType(); 
    186196        void ConnectToRemoteComponent(const char* serverName, \ 
    187                 const char* serverPort); 
     197                const char* serverPort, const bool SML); 
    188198        void WaitForSignal(); 
    189199        void Shutdown(); 
     
    235245        void SendComponentType(); 
    236246        void ConnectToRemoteComponent(const char* serverName, \ 
    237                 const char* serverPort); 
     247                const char* serverPort, const bool SML); 
    238248        void WaitForSignal(); 
    239249        void Shutdown(); 
  • vtcross/trunk/src/policy_engines/PolicyEngine.cpp

    r202 r203  
    4040    LOG("Creating Policy Engine.\n"); 
    4141 
    42     SML_present = SML; 
    43      
    44     ConnectToRemoteComponent(serverName, serverPort); 
     42    ConnectToRemoteComponent(serverName, serverPort, SML); 
    4543 
    4644    LoadPolicies(); 
     
    5856void 
    5957PolicyEngine::ConnectToRemoteComponent(const char* serverName, \ 
    60         const char* serverPort) 
     58        const char* serverPort, const bool SML) 
    6159{ 
    6260    commandSocketFD = ClientSocket(serverName, serverPort); 
    6361 
    64     if(SML_present) { 
     62    SML_present = SML; 
     63 
     64    if(SML) { 
    6565        RegisterServices(); 
    6666        LOG("Policy Engine connected to SML at %s.\n", serverName); 
     
    115115                close(commandSocketFD); 
    116116 
    117                 SML_present = true; 
    118  
    119                 ConnectToRemoteComponent(serverName, serverPort); 
     117                ConnectToRemoteComponent(serverName, serverPort, true); 
    120118            } 
    121119        } 
     
    140138                close(commandSocketFD); 
    141139 
    142                 SML_present = false; 
    143  
    144                 ConnectToRemoteComponent(serverName, serverPort); 
     140                ConnectToRemoteComponent(serverName, serverPort, false); 
    145141            } 
    146142        } 
     
    179175    else 
    180176        DeregisterComponent(); 
    181  
    182     SML_present = false; 
    183     commandSocketFD = -1; 
    184     LoadPolicies(); 
    185177} 
    186178 
     
    202194    shutdown(commandSocketFD, 2); 
    203195    close(commandSocketFD); 
     196    commandSocketFD = -1; 
    204197    LOG("Policy Engine:: Shell socket closed.\n"); 
    205198} 
     
    228221    shutdown(commandSocketFD, 2); 
    229222    close(commandSocketFD); 
     223    commandSocketFD = -1; 
    230224    LOG("Policy Engine:: SML socket closed.\n"); 
    231225}