How AutoScript Supports Intelligent Agent Technology
The Intelligent Agents in kosmosBOS are implemented using AutoScript as well. In order to support this technology, AutoScript implements some extra keywords and constructs to do the job.
start_agent_info...end_agent_info
We use them to define the basic elements of the agent. For example:
start_agent_info
AgentName = "first_agent"
AgentDescr = ""
AgentLanguage = ""
__timer_interval = 0{....define (in seconds) the timer interval for the wake up}
__is_registered = 1{.....1=the agent keeps trail to database, 0=starting without trail}
__delete_on_termination = 0{....1=the agent frees itself when terminates its task}
end_agent_info
start_action...end_action
They include the code that executes when the agent is activated
{....................................ACTION CODE..............................................}
start_action
callwait bpm_assign_job ("do job one","John","")
callwait bpm_assign_job ("do job two","Peter","")
callwait bpm_assign_job ("do job three","Matthew","")
end_action
start_bpm_activity...end_bpm_activity
start_bpm_subactivity...end_bpm_subactivity
start_bpm_validation...end_bpm_validation
Those keywords are used to define user activities. They include the code of the agent executed on the client side. For example:
start_bpm_activity "New Request"
start_bpm_subactivity "Define new request's elements"
rec = bpm_getrecid()
if rec = 0 then
call OpenFormModal("ptAppend","REQUEST02.FM","WORK.REQUEST",1,"?=REQUEST")
else
expr = strcat(rec,"=REQUEST")
call OpenFormModal("ptEdit","REQUEST02.FM","WORK.REQUEST",1,expr)
endif
end_bpm_subactivity
start_bpm_validation
result = 1
rec = bpm_getrecid()
if rec = 0 then
call message("Order does not defined!")
result = 0 {....do not return to server}
endif
end_bpm_validation
end_bpm_activity
We can have any number of start_bpm_subactivity...end_bpm_subactivity into a user's activity.
callwait
This is used only for bpm_assign_job and agent_run. The agent action code does not continue until those procedures are returned control to the agent. For example:
callwait bpm_assign_job ("do job one","John","")
callwait agent_run(ag)
split_in_branches...and_branch...join_branches
Parallel splinting is implemented in the following example
split_in_branches
callwait bpm_assign_job ("do job one","John","")
and_branch
callwait bpm_assign_job ("do job two","Peter","")
and_brach
callwait bpm_assign_job ("do job three","Matthew","")
join_branches
a = 10
The command (a = 10) will be executed only after John, Peter, and Matthew finish their activities. Take in mind that in this example we know in advance the number of parallel splits of the code. In cases where the number of parallel splits defined by code, for example (x), we have the following construct.
split_for...next_branch
We use this type of parallel splinting when the number of splits is not known in advance. For example:
split_for i = 1 to user_count
callwait bpm_assign_job ("do your job",user[i],"")
next_branch
a = 10
The command (a = 10) will be executed only after user_count jobs are assigned to those users and then return finished by them.