00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 #ifndef _MOBILEC_H_
00126 #define _MOBILEC_H_
00127
00128 #include "macros.h"
00129
00130 #ifdef WIN32
00131 #ifdef _MC_DLL
00132
00133 #define EXPORTMC _declspec(dllexport)
00134 #else
00135
00136 #define EXPORTMC
00137 #endif
00138 #else
00139
00140 #define EXPORTMC
00141 #endif
00142
00143
00144
00145 #define MC_Wait(arg1) \
00146 MC_MainLoop(arg1)
00147
00148 #include <embedch.h>
00149 #ifdef __cplusplus
00150 extern "C" {
00151 #endif
00152
00153
00154
00155 struct agent_s;
00156 typedef int (*MC_AgentInitCallbackFunc_t)(
00157 ChInterp_t interp,
00158 struct agent_s* agent,
00159 void* user_data);
00160
00161 #ifndef _ERROR_CODE_E_
00162 #define _ERROR_CODE_E_
00163
00164
00165
00166
00167 typedef enum error_code_e {
00168 MC_SUCCESS = 0,
00169 MC_ERR,
00170 MC_ERR_CONNECT,
00171 MC_ERR_PARSE,
00172 MC_ERR_EMPTY,
00173 MC_ERR_INVALID,
00174 MC_ERR_INVALID_ARGS,
00175 MC_ERR_NOT_FOUND,
00176 MC_ERR_MEMORY,
00177 MC_ERR_SEND,
00178 MC_WARN_DUPLICATE
00179 } error_code_t;
00180 #endif
00181
00185 enum MC_ThreadIndex_e{
00186 MC_THREAD_DF=0,
00187 MC_THREAD_AMS,
00188 MC_THREAD_ACC,
00189 MC_THREAD_CP,
00190 MC_THREAD_AGENT,
00191 MC_THREAD_ALL };
00192
00193
00197 typedef enum MC_SteerCommand_e {
00198 MC_RUN = 0,
00199 MC_SUSPEND,
00200 MC_RESTART,
00201 MC_STOP
00202 } MC_SteerCommand_t;
00203
00212 enum MC_Signal_e{
00213 MC_NO_SIGNAL =0x00,
00214 MC_RECV_CONNECTION=0x01,
00215 MC_RECV_MESSAGE =0x02,
00216 MC_RECV_AGENT =0x04,
00217 MC_RECV_RETURN =0x08,
00218 MC_EXEC_AGENT =0x10,
00219 MC_ALL_SIGNALS =0x20
00220 };
00221
00225 typedef struct agency_s {
00226 int client;
00227 int server;
00228 char *hostName;
00229 char *filename;
00230 int portno;
00231 int portnoc;
00232 int initInterps;
00233 struct mc_platform_s* mc_platform;
00234 int default_agentstatus;
00235 int threads;
00236 int enable_security;
00237 int stack_size[MC_THREAD_ALL];
00238 int bluetooth;
00239
00240 char* priv_key_filename;
00241 char* known_host_filename;
00242 error_code_t last_error;
00243
00244
00245 MC_AgentInitCallbackFunc_t agentInitCallback;
00246 void* agentInitUserData;
00247 } agency_t;
00248 typedef agency_t* agency_p;
00249 typedef agency_p MCAgency_t;
00250
00254 typedef struct MCAgencyOptions_s{
00255 int threads;
00256 int default_agent_status;
00257 int modified;
00258 int enable_security;
00259 unsigned char passphrase[32];
00261
00262 int stack_size[MC_THREAD_ALL];
00264 char *known_host_filename;
00265 char *priv_key_filename;
00266 int initInterps;
00267 int bluetooth;
00268 ChOptions_t* ch_options;
00269 } MCAgencyOptions_t;
00270
00271 typedef struct stationary_agent_info_s{
00272 void* args;
00273 struct agent_s* agent;
00274 MCAgency_t attr;
00275 MCAgency_t agency;
00276 THREAD_T thread;
00277 } stationary_agent_info_t;
00278
00279 #ifndef AGENT_T
00280 #define AGENT_T
00281 typedef struct agent_s agent_t;
00282 typedef agent_t* MCAgent_t;
00283 typedef agent_t* agent_p;
00284 #endif
00285
00286 enum MC_AgentType_e{ MC_NONE = -1, MC_REMOTE_AGENT = 0, MC_LOCAL_AGENT, MC_RETURN_AGENT };
00287
00291 enum MC_AgentStatus_e{
00292 MC_NO_STATUS = -1,
00293 MC_WAIT_CH = 0,
00294 MC_WAIT_MESSGSEND,
00295 MC_AGENT_ACTIVE,
00296 MC_AGENT_NEUTRAL,
00297 MC_AGENT_SUSPENDED,
00298 MC_WAIT_FINISHED
00299 };
00300
00302 struct fipa_acl_message_s;
00303 #ifndef _FIPA_PERFORMATIVE_E_
00304 #define _FIPA_PERFORMATIVE_E_
00305 enum fipa_performative_e
00306 {
00307 FIPA_ERROR=-1,
00308 FIPA_ZERO,
00309 FIPA_ACCEPT_PROPOSAL,
00310 FIPA_AGREE,
00311 FIPA_CANCEL,
00312 FIPA_CALL_FOR_PROPOSAL,
00313 FIPA_CONFIRM,
00314 FIPA_DISCONFIRM,
00315 FIPA_FAILURE,
00316 FIPA_INFORM,
00317 FIPA_INFORM_IF,
00318 FIPA_INFORM_REF,
00319 FIPA_NOT_UNDERSTOOD,
00320 FIPA_PROPOGATE,
00321 FIPA_PROPOSE,
00322 FIPA_PROXY,
00323 FIPA_QUERY_IF,
00324 FIPA_QUERY_REF,
00325 FIPA_REFUSE,
00326 FIPA_REJECT_PROPOSAL,
00327 FIPA_REQUEST,
00328 FIPA_REQUEST_WHEN,
00329 FIPA_REQUEST_WHENEVER,
00330 FIPA_SUBSCRIBE
00331 };
00332 #endif
00333
00341 EXPORTMC int
00342 MC_AclDestroy(struct fipa_acl_message_s* message);
00343
00349 EXPORTMC extern struct fipa_acl_message_s*
00350 MC_AclNew(void);
00351
00360 EXPORTMC extern int MC_AclPost(MCAgent_t agent, struct fipa_acl_message_s* message);
00361
00372 EXPORTMC extern struct fipa_acl_message_s*
00373 MC_AclReply(struct fipa_acl_message_s* acl_message);
00374
00382 EXPORTMC extern struct fipa_acl_message_s* MC_AclRetrieve(MCAgent_t agent);
00383
00392 EXPORTMC extern int MC_AclSend(MCAgency_t attr, struct fipa_acl_message_s* acl);
00393
00401 EXPORTMC extern struct fipa_acl_message_s* MC_AclWaitRetrieve(MCAgent_t agent);
00402
00403
00404 enum fipa_performative_e;
00405 enum fipa_protocol_e;
00406
00407 EXPORTMC enum fipa_protocol_e MC_AclGetProtocol(
00408 struct fipa_acl_message_s* acl);
00409
00410 EXPORTMC char* MC_AclGetConversationID(
00411 struct fipa_acl_message_s* acl);
00412
00413 EXPORTMC enum fipa_performative_e MC_AclGetPerformative(
00414 struct fipa_acl_message_s* acl);
00415
00416 EXPORTMC int MC_AclGetSender(
00417 struct fipa_acl_message_s* acl,
00418 char** name,
00419
00420 char** address
00421
00422 );
00423
00424 EXPORTMC const char* MC_AclGetContent(
00425 struct fipa_acl_message_s* acl);
00426
00427 EXPORTMC int MC_AclSetProtocol(
00428 struct fipa_acl_message_s* acl,
00429 enum fipa_protocol_e performative );
00430
00431 EXPORTMC int MC_AclSetConversationID(
00432 struct fipa_acl_message_s* acl,
00433 char* id);
00434
00435 EXPORTMC int MC_AclSetPerformative(
00436 struct fipa_acl_message_s* acl,
00437 enum fipa_performative_e performative );
00438
00439 EXPORTMC int MC_AclSetSender(
00440 struct fipa_acl_message_s* acl,
00441 const char* name,
00442 const char* address );
00443
00444 EXPORTMC int MC_AclAddReceiver(
00445 struct fipa_acl_message_s* acl,
00446 const char* name,
00447 const char* address );
00448
00449 EXPORTMC int MC_AclAddReplyTo(
00450 struct fipa_acl_message_s* acl,
00451 const char* name,
00452 const char* address);
00453
00454 EXPORTMC int MC_AclSetContent(
00455 struct fipa_acl_message_s* acl,
00456 const char* content );
00457
00458
00459
00460
00469 EXPORTMC extern int MC_AddAgent(
00470 MCAgency_t attr,
00471 MCAgent_t agent);
00472
00483 int MC_AddStationaryAgent(
00484 MCAgency_t agency,
00485 void* (*agent_thread)(stationary_agent_info_t*),
00486 const char* name,
00487 void* agent_args);
00488
00501 int MC_AddAgentInitCallback(
00502 MCAgency_t agency,
00503 MC_AgentInitCallbackFunc_t function,
00504 void* user_data);
00505
00518 int MC_AgentAddTask(
00519 MCAgent_t agent,
00520 const char* code,
00521 const char* return_var_name,
00522 const char* server,
00523 int persistent);
00524
00537 int MC_AgentAddTaskFromFile(
00538 MCAgent_t agent,
00539 const char* filename,
00540 const char* return_var_name,
00541 const char* server,
00542 int persistent);
00543
00552 extern MCAgency_t
00553 MC_AgentInfo_GetAgency(stationary_agent_info_t* stationary_agent_info);
00554
00565 extern MCAgent_t
00566 MC_AgentInfo_GetAgent(stationary_agent_info_t* stationary_agent_info);
00567
00576 extern void*
00577 MC_AgentInfo_GetAgentArgs(stationary_agent_info_t* stationary_agent_info);
00578
00587 extern int MC_AgentReturnArrayDim(
00588 MCAgent_t agent,
00589 int task_num );
00590
00600 extern int MC_AgentReturnArrayExtent(
00601 MCAgent_t agent,
00602 int task_num,
00603 int index);
00604
00614 extern int MC_AgentReturnArrayNum(
00615 MCAgent_t agent,
00616 int task_num);
00617
00627 extern const void* MC_AgentReturnDataGetSymbolAddr(
00628 MCAgent_t agent,
00629 int task_num );
00630
00639 extern size_t MC_AgentReturnDataSize(
00640 MCAgent_t agent,
00641 int task_num );
00642
00652 extern int MC_AgentReturnDataType(
00653 MCAgent_t agent,
00654 int task_num );
00655
00665 extern int MC_AgentReturnIsArray(
00666 MCAgent_t agent,
00667 int task_num );
00668
00684 extern const void*
00685 MC_AgentVariableRetrieve(
00686 MCAgent_t agent,
00687 const char* var_name,
00688 int task_num);
00689
00704 int
00705 MC_AgentVariableRetrieveInfo(
00706 MCAgent_t agent,
00707 const char* var_name,
00708 int task_num,
00709 const void** data,
00710 int* dim,
00711 const int** extent
00712 );
00713
00731 extern int
00732 MC_AgentVariableSave(MCAgent_t agent, const char* var_name);
00733
00734 EXPORTMC int
00735 MC_Barrier(MCAgency_t attr, int id);
00736
00746 EXPORTMC extern int MC_BarrierDelete(MCAgency_t attr, int id);
00747
00763 EXPORTMC extern int MC_BarrierInit(MCAgency_t attr, int id, int num_procs);
00764
00773 #ifdef OBS
00774 EXPORTMC extern int MC_ChInitializeOptions(MCAgency_t attr, ChOptions_t *options);
00775 #endif
00776
00777
00793 EXPORTMC int
00794 MC_CallAgentFunc(
00795 MCAgent_t agent,
00796 const char* funcName,
00797 void* returnVal,
00798 int numArgs,
00799 ...);
00800
00817 EXPORTMC extern int MC_CallAgentFuncArg(
00818 MCAgent_t agent,
00819 const char* funcName,
00820 void* returnVal,
00821 void* arg
00822 );
00823
00834 EXPORTMC extern int MC_CallAgentFuncV(
00835 MCAgent_t agent,
00836 const char* funcName,
00837 void* returnVal,
00838 va_list ap);
00839
00840
00841
00842
00843
00844
00845
00846
00847 EXPORTMC extern int MC_CallAgentFuncVar
00848 (
00849 MCAgent_t agent,
00850 const char* funcName,
00851 void* returnVal,
00852 ChVaList_t arglist
00853 );
00854
00855
00869 EXPORTMC extern MCAgent_t
00870 MC_ComposeAgent(
00871 const char* name,
00872 const char* home,
00873 const char* owner,
00874 const char* code,
00875 const char* return_var_name,
00876 const char* server,
00877 int persistent
00878 );
00879
00896 EXPORTMC extern MCAgent_t
00897 MC_ComposeAgentS(
00898 const char* name,
00899 const char* home,
00900 const char* owner,
00901 const char* code,
00902 const char* return_var_name,
00903 const char* server,
00904 int persistent,
00905 const char* workgroup_code
00906 );
00907
00923 EXPORTMC extern MCAgent_t
00924 MC_ComposeAgentWithWorkgroup(
00925 const char* name,
00926 const char* home,
00927 const char* owner,
00928 const char* code,
00929 const char* return_var_name,
00930 const char* server,
00931 int persistent,
00932 const char* workgroup_code
00933 );
00934
00949 EXPORTMC extern MCAgent_t
00950 MC_ComposeAgentFromFile(
00951 const char* name,
00952 const char* home,
00953 const char* owner,
00954 const char* filename,
00955 const char* return_var_name,
00956 const char* server,
00957 int persistent
00958 );
00959
00977 EXPORTMC extern MCAgent_t
00978 MC_ComposeAgentFromFileS(
00979 const char* name,
00980 const char* home,
00981 const char* owner,
00982 const char* filename,
00983 const char* return_var_name,
00984 const char* server,
00985 int persistent,
00986 const char* workgroup_code
00987 );
00988
01004 EXPORTMC extern MCAgent_t
01005 MC_ComposeAgentFromFileWithWorkgroup(
01006 const char* name,
01007 const char* home,
01008 const char* owner,
01009 const char* filename,
01010 const char* return_var_name,
01011 const char* server,
01012 int persistent,
01013 const char* workgroup_code
01014 );
01015
01026 EXPORTMC extern int MC_CondBroadcast(MCAgency_t attr, int id);
01027
01043 EXPORTMC extern int MC_CondSignal(MCAgency_t attr, int id);
01044
01055 EXPORTMC extern int MC_CondReset(MCAgency_t attr, int id);
01056
01070 EXPORTMC extern int MC_CondWait(MCAgency_t attr, int id);
01071
01081 int MC_CopyAgent(MCAgent_t* agent_out, const MCAgent_t agent_in);
01082
01091 EXPORTMC extern int MC_DeleteAgent(MCAgent_t agent);
01092
01104 EXPORTMC extern int MC_DeleteAgentWG(MCAgent_t calling_agent, MCAgent_t agent);
01105
01116 EXPORTMC extern int MC_End(MCAgency_t attr);
01117
01128 int MC_DestroyServiceSearchResult(
01129 char** agentName,
01130 char** serviceName,
01131 int* agentID,
01132 int numResult);
01133
01134
01145 EXPORTMC extern MCAgent_t MC_FindAgentByName(MCAgency_t attr, const char *name);
01146
01155 EXPORTMC extern MCAgent_t MC_FindAgentByID(MCAgency_t attr, int ID);
01156
01165 EXPORTMC extern void* MC_GetAgentExecEngine(MCAgent_t agent);
01166
01170 EXPORTMC extern int MC_GetAgentID(MCAgent_t agent);
01171
01172
01173
01174
01175
01176
01177 EXPORTMC extern char* MC_GetAgentName(MCAgent_t agent);
01178
01184 EXPORTMC extern int MC_GetAgentNumTasks(MCAgent_t agent);
01185
01202 EXPORTMC extern int MC_GetAgentReturnData(
01203 MCAgent_t agent,
01204 int task_num,
01205 void **data,
01206 int *dim,
01207 int **extent);
01208
01214 EXPORTMC extern int MC_GetAgentStatus(MCAgent_t agent);
01215
01221 EXPORTMC extern enum MC_AgentType_e MC_GetAgentType(MCAgent_t agent);
01222
01228 EXPORTMC extern char* MC_GetAgentXMLString(MCAgent_t agent);
01229
01237 EXPORTMC extern int MC_HaltAgency(MCAgency_t agency);
01238
01249 EXPORTMC extern MCAgency_t MC_Initialize(
01250 int port,
01251 MCAgencyOptions_t *options);
01252
01265 EXPORTMC extern int MC_InitializeAgencyOptions(struct MCAgencyOptions_s* options);
01266
01272 EXPORTMC extern int MC_MainLoop(MCAgency_t attr);
01273
01282 EXPORTMC extern int MC_LoadAgentFromFile(MCAgency_t attr, const char* filename);
01283
01293 EXPORTMC extern int MC_MigrateAgent(MCAgent_t agent, const char* hostname, int port);
01294
01309 EXPORTMC extern int MC_MutexLock(MCAgency_t attr, int id);
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321 EXPORTMC extern int MC_MutexUnlock(MCAgency_t attr, int id);
01322
01340 EXPORTMC extern int MC_RegisterService(
01341 MCAgency_t agency,
01342
01343
01344
01345 MCAgent_t agent,
01346 int agentID,
01347 const char *agentName,
01348 char **serviceNames,
01349 int numServices);
01350
01358 EXPORTMC extern int MC_ResumeAgency(MCAgency_t agency);
01359
01365 EXPORTMC extern MCAgent_t MC_RetrieveAgent(MCAgency_t attr);
01366
01378 EXPORTMC extern int MC_SemaphorePost(MCAgency_t attr, int id);
01379
01393 EXPORTMC extern int MC_SemaphoreWait(MCAgency_t attr, int id);
01394
01406 EXPORTMC extern int MC_SetDefaultAgentStatus(MCAgency_t agency, enum MC_AgentStatus_e status);
01407
01421 EXPORTMC extern int MC_SetThreadOn(MCAgencyOptions_t *options, enum MC_ThreadIndex_e index);
01422
01431 EXPORTMC extern int MC_SetThreadsAllOn(MCAgencyOptions_t* options);
01432
01446 EXPORTMC extern int MC_SetThreadOff(MCAgencyOptions_t *options, enum MC_ThreadIndex_e index );
01447
01456 EXPORTMC extern int MC_SetThreadsAllOff(MCAgencyOptions_t* options);
01457
01463 EXPORTMC extern int MC_PrintAgentCode(MCAgent_t agent);
01464
01470 EXPORTMC extern char * MC_RetrieveAgentCode(MCAgent_t agent);
01471
01479 EXPORTMC extern int MC_ResetSignal(MCAgency_t attr);
01480
01496 EXPORTMC extern int MC_SearchForService(
01497
01498 MCAgency_t attr,
01499 const char *searchString,
01500
01501 char*** agentNames,
01502 char*** serviceNames,
01503 int** agentIDs,
01504 int* numResults);
01505
01512 EXPORTMC extern int MC_SendAgent(MCAgency_t attr,
01513 const char *message);
01514
01521 EXPORTMC extern int MC_SendAgentFile(MCAgency_t attr,
01522 const char *filename);
01523
01532 EXPORTMC extern int MC_SendAgentMigrationMessage(MCAgency_t attr,
01533 const char *message,
01534 const char *hostname,
01535 int port);
01536
01545 EXPORTMC extern int MC_SendAgentMigrationMessageFile(MCAgency_t attr,
01546 const char *filename,
01547 const char *hostname,
01548 int port);
01549
01558 EXPORTMC extern int MC_SetAgentStatus(MCAgent_t agent, enum MC_AgentStatus_e status);
01559
01575 EXPORTMC extern int MC_Steer( MCAgency_t attr, int (*funcptr)(void* data), void *arg);
01576
01585 EXPORTMC extern enum MC_SteerCommand_e MC_SteerControl(void);
01586
01595 EXPORTMC extern int MC_SyncDelete(MCAgency_t attr, int id);
01596
01612 EXPORTMC extern int MC_SyncInit(MCAgency_t attr, int id);
01613
01619 EXPORTMC extern int MC_TerminateAgent(MCAgent_t agent);
01620
01621
01622 EXPORTMC extern int
01623 MC_TerminateAgentWG(MCAgent_t calling_agent, MCAgent_t agent);
01629
01630
01637 EXPORTMC extern int MC_WaitAgent(MCAgency_t attr);
01638
01647 EXPORTMC extern MCAgent_t MC_WaitRetrieveAgent(MCAgency_t attr);
01648
01662 EXPORTMC extern int MC_WaitSignal(MCAgency_t attr, int signals);
01663
01664 #ifdef __cplusplus
01665 }
01666 #endif
01667
01668 #endif
01669