|
Adun
0.83
|
#import <AdunIOManager.h>
Public Member Functions | |
| (BOOL) | - processCommandLine: |
| (AdCoreRunMode) | - runMode |
| (BOOL) | - restartRequested |
| (void) | - saveResults: |
| (void) | - setSimulationReferences: |
| (void) | - setCore: |
| (NSMutableArray *) | - pluginsPaths |
| (NSString *) | - simulationOutputDirectory |
| (NSString *) | - controllerOutputDirectory |
| (NSString *) | - controllerDirectory |
| (NSString *) | - adunDirectory |
| (NSDictionary *) | - template |
| (NSDictionary *) | - externalObjects |
| (FILE *) | - openFile:usingName:flag: |
| (FILE *) | - getStreamForName: |
| (void) | - closeStreamWithName: |
| (void) | - closeAllStreams |
| (BOOL) | - checkProgramDirectories: |
| (BOOL) | - createSimulationOutputDirectory: |
| (BOOL) | - createControllerOutputDirectory: |
| (BOOL) | - createLogFiles: |
| (BOOL) | - moveLogFilesTo:error: |
| (BOOL) | - connectToServer: |
| (BOOL) | - isConnected |
| (void) | - acceptRequests |
| (void) | - sendControllerResults: |
| (void) | - closeConnection: |
| (BOOL) | - loadData: |
Static Public Member Functions | |
| (id) | + appIOManager |
AdIOManager manages input and output from the simulation application.
Main Attributes
AdIOManager is a singleton - only one instance exists for each application. This instance can be accessed using the appIOManager (AdIOManager) method.
| - (void) acceptRequests |
Causes the AdIOManager instance to indicate to the server that it is ready to process requests. Has no effect if a connection was not created using connectToServer: or the connection attempt failed.
| - (NSString *) adunDirectory |
Returns the program working directory
| + (id) appIOManager |
Returns the applications AdIOManager instance.
| - (BOOL) checkProgramDirectories: | (NSError **) | error |
Checks that the adun/ directory exists and has the correct structure. Uses the value given by the NSUserDefaults key ProgramDirectory for the directory location If it doesnt exist it is created in this location. If the structure of the directory is incorrect i.e. there are missing directories, they structure is corrected. If the program directories can be corrected of fixed this method returns NO and error contains an NSError object that describes the problem.
| - (void) closeAllStreams |
Closes all the stream created using openFile:usingName:flag:.
| - (void) closeConnection: | (NSError *) | error |
Closes the connection to the local AdServer instance. Has no effect if a connection does not exist.
| error | If the connection is being closed for a reason other than normal termination then this should be an NSError object describing the cause. Otherwise pass nil. |
| - (void) closeStreamWithName: | (NSString*) | name |
Closes the stream previously created using openFile:usingName:flag:. name is the name given to the stream when it was created. If no stream called name exists this method does nothing.
| - (BOOL) connectToServer: | (NSError **) | error |
Attempts to connect to the AdServer on the localhost. This allows the server to send commands to the simulation application via the AdCommandInterface protocol.
| error | If an error occurs, upon return contains an NSError object that describes the problem. |
| - (NSString *) controllerDirectory |
Returns the directory where controller plugins are located.
| - (NSString *) controllerOutputDirectory |
Returns the directory to which the controller should write its output.
| - (BOOL) createControllerOutputDirectory: | (NSError **) | error |
Creates the controller output directory
| - (BOOL) createLogFiles: | (NSError **) | error |
Creates the program and error log files. Uses the values given by NSUserDefaults keys LogFile and ErrorFile for the file locations. Returns YES on succesful creation. If the log files could not be created returns NO and error contains an NSError object that describes the problem.
| - (BOOL) createSimulationOutputDirectory: | (NSError **) | error |
Creates the simulation output directory
| - (NSDictionary*) externalObjects |
Returns any external objects retrieved from the server or nil if there are none.
| - (FILE *) getStreamForName: | (NSString*) | name |
Returns the stream associated with name. The stream must have been previously created using openFile:usingName:flag:. If no stream called name exists this method return NULL.
| name | The name associated with the stream when it was created. |
| - (BOOL) isConnected |
Returns YES if the receiver is connected to an AdServer instance. NO otherwise.
| - (BOOL) loadData: | (NSError **) | error |
Retrieves and processes the program data as specified by the program arguements. Returns YES if the required data was loaded successfully. Returns NO otherwise. If NO is returned error is set with an NSError object explaining the reason the data could not loaded. If processCommandLine: has not been called this method calls it.
The log files are copied to the simulation output directory if the RedirectOutput default is YES.
| - (BOOL) moveLogFilesTo: | (NSString *) | dataDirectory | |
| error: | (NSError **) | error | |
Moves the log files (stdout and stderr) to dataDirectory. This method is used to move the log files to the simulation data directory (if RedirectOutput default is YES) and should not usually be called externally.
| - (FILE *) openFile: | (NSString*) | file | |
| usingName: | (NSString*) | name | |
| flag: | (NSString*) | fileFlag | |
Creates a stream to file. The mode of the stream is detemined by fileFlag. If file is nil or the stream cannot be created this method return NULL. fileFlag also determines if the file should be created if it does not exist.
| file | The path to the file. |
| name | The name to be associated with this stream. For use with getStreamForName() and closeStreamWithName(). |
| flag | Inidicates this mode for the stream. Value are the same as for the libc function fopen(). |
| - (NSMutableArray*) pluginsPaths |
Returns paths where controllers may be located
| - (BOOL) processCommandLine: | (NSError**) | error |
Checks that the format of the command line arguements is valid, that all the arguement keys are valid and that required arguement are present. On detecting a problem returns NO and error contains an NSError object detailing the problem encountered.
| - (BOOL) restartRequested |
Returns YES if a simulation continuation was requested via the command line arguments. NO otherwise.
| - (AdCoreRunMode) runMode |
Returns the runMode of the core. AdCoreServerRunMode, AdCoreCommandLineRunMode.
| - (void) saveResults: | (NSArray*) | anArray |
Saves the entries in array to the controller output directory. Each entry must be an AdDataSet instance. If not an NSInvalidArgumentException is raised.
| - (void) sendControllerResults: | (NSArray *) | anArray |
Sends the data sets in array anArray to the server. If the program is not connected to a server this method does nothing.
| - (void) setCore: | (id) | core |
Sets a reference to the AdCore instance of the simulator.
| - (void) setSimulationReferences: | (NSDictionary*) | inputObjects |
Adds references to the objects in inputObjects to the simulation data instance. This method also adds the simulation template to the AdSimulationData objects metadata and sends the simulation data to the server if the receiver is connected to one.
| - (NSString *) simulationOutputDirectory |
Returns the name of the directory to which simulation output is written.
| - (NSDictionary *) template |
Returns the template for the simulation or nil if none has been loaded.
1.8.1