WebService in JSON_RPC v. 1.1 API

Now you can use simple remote procedure calls to contact generator engine and your timetables. To do it you need a special rpc account created by service administrator. Timetables data exchanged with the timetable engine comply XSD format defined at: http://www.school-timetable.eu/t4s_v10.xsd
Below it is simple example in Ruby how you can operate the timetable generator by using rpc calls:

class RpcClient < JsonRpcClient
json_rpc_service 'http://www.school-timetable.eu/api'
end

def compress(term)
Zlib::Deflate.deflate(term)
end

def decompress(term)
Zlib::Inflate.inflate(term)
end

def rpctest

# Logs into service. Args: version, user, password
ses=RpcClient.login 1,'user','password'
puts "Session:"+ses


# Runs the generator
# Args: session, plan_id, maxtime[min], base[0,1], find_close[0,1], teacher_gaps_mode, room_mode, room_count_only[0,1], optym_mode, optym_from
# a)teacher_gaps_mode:
# -2: Default
# -1: Do not take into account
# 0: Selected teachers - No gaps
# 1: Selected teachers - One a day (one hour)
# 2: Selected teachers - One break a day (several hours)
# b) room_mode
# 0: Priority:min displacements and pref room for st.body,then for a teacher,pref room for a subject">Minimize student bodies displacement
# 1: Priority:min displacements and pref room for a teacher,then for st.body,pref room for a subject">Minimize teachers displacement
# 2: Priority:pref room for a subject,then minimize displacements and pref room for st.body and a teacher">Pref rooms for subj,student body shift
# 3: Priority:pref room for a subject,then min displacements and pref room for a teacher and st.body">Pref rooms for subj,teacher shift
# 4: Priority:pref room and displacements for st.body,then for a teacher,pref room for a subject">Prefered rooms for student bodies
# 5: Priority:pref room and displacements for a teacher,then for st.body,pref room for a subject">Prefered rooms for teachers
# 6: Priority:pref room for a subject,then pref room and min displacements for st.body and a teacher" selected>Pref rooms for subj,student body
# 7: Priority:pref room for a subject,then pref room and min displacements for a teacher and st.body">Pref rooms for subj, teachers
# c) optym_mode
# None
# Fast
# Normal
# Iterative - big step
# Iterative - small step

str=RpcClient.run ses,697,10,0,1,-2,2,1,1,3
puts "Timetables:"+str

# Status of generator execution
# Returns: off=>0,:scheduled=>1,:running=>2,:done=>3,stopped=>4,:waiting=>5
str=RpcClient.status ses,697
puts "Timetables:"+str

# Stops execution of generator
str=RpcClient.stop ses,697
puts "Timetables:"+str

# Loads a timetable from XML
timXML=File.read("tim.xml")
tim_id=RpcClient.putT4s ses,CGI.escape(compress(timXML))
puts "ID of Timetable:"+tim_id

# Remove timetable
str=RpcClient.remove ses,712
puts "Removed:"+str

# Returns list of timetable ids. Example 100, 101, 321,
str=RpcClient.list ses
puts "Timetables:"+str

# Gets timetable with results
tim_xml=RpcClient.getT4s ses,711
puts "Timetable XML:"+decompress(CGI.unescape(tim_xml))
end