remoteControlInterface.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 
00009 
00010 
00011 #pragma once
00012 
00013 #include "lgrSim.h"
00014 
00015 #include <lcRemoteLoggerConnection.h>
00016 
00017 #include <vlutil/vlString.h>
00018 #include <vlpi/entityIdentifier.h>
00019 
00020 #include <list>
00021 #include <map>
00022 #include <set>
00023 
00024 class DtExerciseConn;
00025 class DtInteraction;
00026 class DtLgrControlPdu;
00027 class DtEntityIdentifier;
00028 class DtLgrAcknowledgePdu;
00029 class DtLgrConnectPdu;
00030 class DtLgrDisconnectPdu;
00031 class DtLgrLgrHeartbeatPdu;
00032 class DtLgrResponsePdu;
00033 class DtLgrTotalStatePdu;
00034 
00035 namespace MAKLogger
00036 {
00037    class DtAbsoluteTime;
00038    class DtRelativeTime;
00039    class DtCommand;
00040    class DtRemoteControlDomainInterface;
00041    class DtRemoteControlSystemInterface;
00042    class DtRemoteControlPlaybackInterface;
00043    class DtRemoteControlRecordInterface;
00044    class DtRemoteControlEditorInterface;
00045    class DtRemoteControlSimulationInterface;
00046    class DtRemoteControlSharedInterface;
00047 
00048    typedef DtU32 DtSequenceNumber;
00049    typedef std::set<DtSequenceNumber> DtSequenceNumberSet;
00050    typedef std::set<DtEntityIdentifier> DtEntityIdSet;
00051 
00052    typedef void (*DtLgrConnectCb)( DtLgrConnectPdu* connect, void* usr );
00053    typedef void (*DtLgrDisconnectCb)( DtLgrDisconnectPdu* connect, void* usr );
00054    typedef void (*DtLgrLgrHeartbeatCb)( DtLgrLgrHeartbeatPdu* connect, void* usr );
00055    typedef void (*DtLgrAcknowledgeCb)( DtLgrAcknowledgePdu* connect, void* usr );
00056    typedef void (*DtLgrResponseCb)( DtLgrResponsePdu* connect, void* usr );
00057    typedef void (*DtLgrTotalStateCb)( DtLgrTotalStatePdu* connect, void* usr );
00058    typedef void (*DtLgrConnectionAddedCb)( const DtRemoteLoggerConnection& loggerConnection, void* usr );
00059    typedef void (*DtLgrConnectionRemovedCb)( const DtRemoteLoggerConnection& loggerConnection, void* usr );
00060    typedef void (*DtLgrConnectionTimedOutCb)( const DtRemoteLoggerConnection& loggerConnection, void* usr );
00061 
00062    typedef void (*DtLgrCommandAcceptedCb)( DtSequenceNumber sequenceNumber, void* usr );
00063    typedef void (*DtLgrCommandRejectedCb)(const DtEntityIdentifier& source,  DtSequenceNumber sequenceNumber, void* usr );
00064    typedef void (*DtLgrCommandTimedOutCb)( DtSequenceNumber sequenceNumber, void* usr );
00065    
00066 
00071    class DT_DLL_LGRSIM DtRemoteControlInterface
00072    {
00073    public:
00077       DtRemoteControlInterface(int numberOfLoggersToManage=0);
00078 
00080       virtual ~DtRemoteControlInterface();
00081 
00082    private:
00084       DtRemoteControlInterface(const DtRemoteControlInterface&);
00086       DtRemoteControlInterface& operator=(const DtRemoteControlInterface&);
00087 
00088    public:
00089 
00091       virtual void setConnection(DtExerciseConn* exconn, const DtEntityIdentifier& entityId);
00092 
00095       virtual void clearConnection();
00096 
00098       virtual void disconnect(const DtEntityIdentifier& entityId);
00099 
00101       virtual void tick();
00102 
00104 
00105       virtual void setId( const DtEntityIdentifier& id );
00106       virtual const DtEntityIdentifier& id() const;
00108 
00110 
00111       virtual void setAcceptAnyId( bool acceptAny);
00112       virtual bool acceptAnyId() const;
00114 
00116 
00117       virtual DtTime connectionTimeout() const;
00118       virtual void setConnectionTimeout(DtTime val);
00120 
00122 
00123       virtual void setNumberOfLoggers(int numberOfLoggersToManage);
00124       virtual int numberOfLoggers() const;
00126 
00128       virtual void getConnectionIds(DtEntityIdSet& connectedLoggers) const;
00129 
00131       virtual void getConnectionIds(DtEntityIdSet& connectedLoggers,
00132          const DtEntityIdentifier& idFilter) const;
00133 
00135       virtual DtRemoteLoggerConnection* getConnection(const DtEntityIdentifier& id);
00136 
00138       virtual DtTime lowestTime() const;
00139 
00141       virtual DtTime highestTime() const;
00142 
00144 
00145       virtual DtRemoteControlSystemInterface* systemInterface();
00146       virtual DtRemoteControlPlaybackInterface* playbackInterface();
00147       virtual DtRemoteControlRecordInterface* recordInterface();
00148       virtual DtRemoteControlEditorInterface* editorInterface();
00149       virtual DtRemoteControlSimulationInterface* simulationInterface();
00150       virtual DtRemoteControlSharedInterface* sharedInterface();
00152 
00157       virtual DtSequenceNumber sendCommandMessage(const DtCommand& command,
00158          const DtEntityIdentifier& target=theWildcardAddress);
00159 
00165       virtual DtSequenceNumber sendCommandMessage(const DtCommand& command,
00166          DtRemoteControlDomainInterface* domainInterface,
00167          const DtEntityIdentifier& target=theWildcardAddress);
00168 
00173       virtual DtSequenceNumber sendLoggerControlMessage(DtLgrControlPdu& lgrControl,
00174          const DtEntityIdentifier& target=theWildcardAddress);
00175 
00181       virtual DtSequenceNumber sendLoggerControlMessage(DtLgrControlPdu& lgrControl,
00182          DtRemoteControlDomainInterface* domainInterface,
00183          const DtEntityIdentifier& target=theWildcardAddress);
00184 
00186 
00187       virtual void addCallback( DtLgrConnectCb cb, void* user );
00188       virtual void removeCallback( DtLgrConnectCb );
00189 
00190       virtual void addCallback( DtLgrDisconnectCb cb, void* user );
00191       virtual void removeCallback( DtLgrDisconnectCb );
00192 
00193       virtual void addCallback( DtLgrLgrHeartbeatCb cb, void* user );
00194       virtual void removeCallback( DtLgrLgrHeartbeatCb );
00195 
00196       virtual void addCallback( DtLgrAcknowledgeCb cb, void* user );
00197       virtual void removeCallback( DtLgrAcknowledgeCb );
00198 
00199       virtual void addCallback( DtLgrResponseCb cb, void* user );
00200       virtual void removeCallback( DtLgrResponseCb );
00201 
00202       virtual void addCallback( DtLgrTotalStateCb cb, void* user );
00203       virtual void removeCallback( DtLgrTotalStateCb );
00204 
00205       virtual void addCallbackConnectionAdded( DtLgrConnectionAddedCb cb, void* user );
00206       virtual void removeCallbackConnectionAdded( DtLgrConnectionAddedCb );
00207 
00208       virtual void addCallbackConnectionRemoved( DtLgrConnectionRemovedCb cb, void* user );
00209       virtual void removeCallbackConnectionRemoved( DtLgrConnectionRemovedCb );
00210 
00211       virtual void addCallbackConnectionTimedOut( DtLgrConnectionTimedOutCb cb, void* user );
00212       virtual void removeCallbackConnectionTimedOut( DtLgrConnectionTimedOutCb );
00213 
00214       virtual void addCallbackCommandAccepted( DtLgrCommandAcceptedCb cb, void* user );
00215       virtual void removeCallbackCommandAccepted( DtLgrCommandAcceptedCb );
00216 
00217       virtual void addCallbackCommandRejected( DtLgrCommandRejectedCb cb, void* user );
00218       virtual void removeCallbackCommandRejected( DtLgrCommandRejectedCb );
00219 
00220       virtual void addCallbackCommandTimedOut( DtLgrCommandTimedOutCb cb, void* user );
00221       virtual void removeCallbackCommandTimedOut( DtLgrCommandTimedOutCb );
00222 
00224 
00225    public:
00226 
00228       static const DtEntityIdentifier& wildcardAddress();
00229 
00231       static const char* commandToString(int domain, int command);
00232 
00233    protected:
00234 
00236       virtual void lgrCtrlCallback( DtInteraction* );
00237 
00239       virtual void processControlPdus();
00240 
00242       virtual void checkConnections();
00243 
00245       virtual bool isIdMatching(const DtEntityIdentifier& targetId, bool allowWildCard=true);
00246 
00248       virtual DtSequenceNumber nextSequenceNumber();
00249 
00251 
00252       virtual void processTotalState(DtLgrTotalStatePdu* totalStatePdu);
00253       virtual void processConnect(DtLgrConnectPdu* connectPdu);
00254       virtual void processDisconnect(DtLgrDisconnectPdu* disconnectPdu);
00255       virtual void processLgrHeartbeat(DtLgrLgrHeartbeatPdu* lgrHeartbeatPdu);
00256       virtual void processAcknowledge(DtLgrAcknowledgePdu* acknowledgePdu);
00257       virtual void processResponse(DtLgrResponsePdu* responsePdu);
00259 
00261       virtual void commandAccepted(DtSequenceNumber sequenceNumber);
00262 
00264       virtual void commandRejected(const DtEntityIdentifier& source, DtSequenceNumber sequenceNumber);
00265 
00267       virtual void commandTimedOut(DtSequenceNumber sequenceNumber);
00268 
00269 
00270    protected:
00271 
00273       static void lgrCtrlCb( DtInteraction*, void* );
00274 
00275    protected:
00276 
00278       typedef struct DtPendingAcknowledge
00279       {
00280          DtTime timeout;
00281          DtEntityIdSet pending;
00282       } DtPendingAcknowledge;
00283 
00284       typedef std::map<DtSequenceNumber, DtPendingAcknowledge> DtPendingAcknowledgeList;
00285       typedef std::map<DtSequenceNumber, DtTime> DtRejectCommandList;
00286       typedef std::map<DtSequenceNumber, DtRemoteControlDomainInterface*> DtAcknowledgeDomainMap;
00287 
00288       typedef std::list<DtLgrControlPdu*> DtPduList;
00289 
00290    protected:
00291 
00292 
00293       DtExerciseConn* myExerciseCon;
00294       DtEntityIdentifier myId;
00295       DtSequenceNumber mySequenceNumber;
00296       DtPduList myPduList;
00297       DtRemoteLoggerMap myRemoteLoggers;
00298       DtEntityIdSet myRemoteLoggerIds;
00299       DtEntityIdSet myRejectedLoggerIds;
00300       bool myAcceptAnyId;
00301       DtTime myConnectionTimeout;
00302       DtTime myNextTimeoutCheck;
00303       DtPendingAcknowledgeList myPendingAcknowledgements;
00304       DtRejectCommandList myRejectedCommands;
00305       DtTime MyAcknowledgeTimeout;
00306       int myNumberOfLoggers;
00307       DtAcknowledgeDomainMap myAcknowledgeInterface;
00308 
00309       std::map<DtLgrConnectCb, void*> myConnectCallbacks;
00310       std::map<DtLgrDisconnectCb, void*> myDisconnectCallbacks;
00311       std::map<DtLgrAcknowledgeCb, void*> myAcknowledgeCallbacks;
00312       std::map<DtLgrResponseCb, void*> myResponseCallbacks;
00313       std::map<DtLgrTotalStateCb, void*> myTotalStateCallbacks;
00314       std::map<DtLgrLgrHeartbeatCb, void*> myHeartbeatCallbacks;
00315       std::map<DtLgrConnectionAddedCb, void*> myConnectionAddedCallbacks;
00316       std::map<DtLgrConnectionRemovedCb, void*> myConnectionRemovedCallbacks;
00317       std::map<DtLgrConnectionTimedOutCb, void*> myConnectionTimedOutCallbacks;
00318       std::map<DtLgrCommandAcceptedCb, void*> myCommandAcceptedCallbacks;
00319       std::map<DtLgrCommandRejectedCb, void*> myCommandRejectedCallbacks;
00320       std::map<DtLgrCommandTimedOutCb, void*> myCommandTimedOutCallbacks;
00321 
00322       DtRemoteControlSystemInterface* mySystemInterface;
00323       DtRemoteControlPlaybackInterface* myPlaybackInterface;
00324       DtRemoteControlRecordInterface* myRecordInterface;
00325       DtRemoteControlEditorInterface* myEditorInterface;
00326       DtRemoteControlSimulationInterface* mySimulationInterface;
00327       DtRemoteControlSharedInterface* mySharedInterface;
00328 
00329    protected:
00330       static const DtU16 theAddressWildcard = ((1<<16)-1); // 65535 or 0xFFFF
00331       static const DtEntityIdentifier theWildcardAddress;
00332 
00333    };
00334 }

Document ID: Generated on Tue Oct 11 19:41:03 EDT 2011 from SVN revision 107422
Copyright © 2005-2011 VT MÄK Inc. All Rights Reserved (www.mak.com)