DSIMA
 All Classes Namespaces Files Functions Variables
client.js File Reference

Functions

function connect ()
 Connection to the server by opening a websocket. More...
 
function onOpen (evt)
 Action when websocket is opened. More...
 
function onClose (evt)
 Action when websocket is closed. More...
 
function onMessage (evt)
 Action when websocket receive a message. More...
 
function onError (evt)
 Action when there is an error with the websocket. More...
 
function send (message)
 Send a message through the websocket assuming it is connected. More...
 
function disconnect ()
 Disconnect the websocket if it is existing. More...
 
function callNextHandler ()
 Call the next handler if one exists. More...
 
function callNextRequest ()
 Call the next handler if there is only one. More...
 
function deleteInstance (h)
 Delete an instance from the server. More...
 
function resetInstance (h)
 Reset an instance from the server. More...
 
function requestInstanceSimulation (h)
 Request the instance simulation interaction. More...
 
function instanceSimulation (h)
 
function instanceGeneration (h)
 Check if the server agreed to receive the instance parameters and sends it. More...
 
function listGeneratedInstances (h)
 List the generated instances by the server. More...
 
function getInstance (h)
 Get an instance from the server. More...
 
function getDailyResult (h)
 Get a daily result of an instance from the server. More...
 
function getGlobalResults (h)
 Fetch the XML result file with the global result. More...
 
function isComputingSimulation (h)
 Poll the server to know if it is computing. More...
 
function connectionButtonManagement ()
 Manage the connection button. More...
 
document ready (function(){if($('#server').prop('value')===""){$('#server').prop('value', server);}else{server=$('#server').prop('value');}$('#connectionButton').click(connectionButtonManagement);$('#disconnectRunButton').click(function(){disconnectAndRun=true;});$('#generateInstance').click(function(){requestHandlers.push({handler:instanceGeneration});callNextRequest();});$('#simulateInstance').click(function(){$('#simulateInstance').hide();requestHandlers.push({handler:requestInstanceSimulation});callNextRequest();});$('#resetInstance').click(function(){hash=$("#instanceSelect").val();if(hash!=="new"&&confirm("Are you sure to reset instance \""+hash+"\"?")){requestHandlers.push({handler:resetInstance, hash:hash});callNextRequest();}});$('#instanceSelect').change(function(){hash=$("#instanceSelect").val();requestHandlers.push({handler:getInstance, hash:hash});callNextRequest();});$('#instanceDelete').click(function(){hash=$("#instanceSelect").val();if(hash!=="new"&&confirm("Are you sure to delete instance \""+hash+"\"?")){requestHandlers.push({handler:deleteInstance, hash:hash});callNextRequest();}});$('#getDailyResultButton').click(function(){hash=$("#instanceSelect").val();day=$("#dayResultsSelect").val();requestHandlers.push({handler:getDailyResult, hash:hash, day:day});callNextRequest();});$('#progressTab').hide();$('#loading').hide();$('#disconnectRunButton').hide();requestHandlers.push({handler:isComputingSimulation});requestHandlers.push({handler:listGeneratedInstances});callNextRequest();})
 
window unload (function(){disconnect();})
 

Variables

var server ="ws://139.165.16.33:8000/"
 This file contains the javascript client of the engine. More...
 
var websocket = null
 Current websocket. More...
 
var POLLING_DELAY =1000
 Polling delay in milliseconds. More...
 
var nextHandlers = []
 List of dictionaries. More...
 
var requestHandlers =[]
 Requests of non started actions. More...
 
var isHandlerProcessing =false
 True if there is an handler prossessing. More...
 
var States ={SENT:0,WAIT:1,RECEIVED:2,GENERATING:3,POLL:4}
 Predefined states. More...
 
var disconnectAndRun =false
 Instance simulation interaction. More...
 

Function Documentation

function callNextHandler ( )

Call the next handler if one exists.

function callNextRequest ( )

Call the next handler if there is only one.

function connect ( )

Connection to the server by opening a websocket.

function connectionButtonManagement ( )

Manage the connection button.

function deleteInstance (   h)

Delete an instance from the server.

Suppose that the state is the hash of the instance to delete.

Parameters
hHandler dictionary.
function disconnect ( )

Disconnect the websocket if it is existing.

function getDailyResult (   h)

Get a daily result of an instance from the server.

Suppose that the hash is provided in the handler dictionary.

Parameters
hHandler dictionary.
function getGlobalResults (   h)

Fetch the XML result file with the global result.

Suppose that the hash is provided in the handler dictionary.

Parameters
hHandler dictionary.
function getInstance (   h)

Get an instance from the server.

Suppose that the state is the hash of the instance to get.

Parameters
hHandler dictionary.
function instanceGeneration (   h)

Check if the server agreed to receive the instance parameters and sends it.

Parameters
hHandler dictionary.
function instanceSimulation (   h)
function isComputingSimulation (   h)

Poll the server to know if it is computing.

Parameters
hHandler dictionary.
function listGeneratedInstances (   h)

List the generated instances by the server.

Parameters
hHandler dictionary.
function onClose (   evt)

Action when websocket is closed.

Parameters
evtEvent.
function onError (   evt)

Action when there is an error with the websocket.

Parameters
evtEvent.
function onMessage (   evt)

Action when websocket receive a message.

Parameters
evtEvent.
function onOpen (   evt)

Action when websocket is opened.

Parameters
evtEvent.
document ready ( function(){if($('#server').prop('value')===""){$('#server').prop('value', server);}else{server=$('#server').prop('value');}$('#connectionButton').click(connectionButtonManagement);$('#disconnectRunButton').click(function(){disconnectAndRun=true;});$('#generateInstance').click(function(){requestHandlers.push({handler:instanceGeneration});callNextRequest();});$('#simulateInstance').click(function(){$('#simulateInstance').hide();requestHandlers.push({handler:requestInstanceSimulation});callNextRequest();});$('#resetInstance').click(function(){hash=$("#instanceSelect").val();if(hash!=="new"&&confirm("Are you sure to reset instance \""+hash+"\"?")){requestHandlers.push({handler:resetInstance, hash:hash});callNextRequest();}});$('#instanceSelect').change(function(){hash=$("#instanceSelect").val();requestHandlers.push({handler:getInstance, hash:hash});callNextRequest();});$('#instanceDelete').click(function(){hash=$("#instanceSelect").val();if(hash!=="new"&&confirm("Are you sure to delete instance \""+hash+"\"?")){requestHandlers.push({handler:deleteInstance, hash:hash});callNextRequest();}});$('#getDailyResultButton').click(function(){hash=$("#instanceSelect").val();day=$("#dayResultsSelect").val();requestHandlers.push({handler:getDailyResult, hash:hash, day:day});callNextRequest();});$('#progressTab').hide();$('#loading').hide();$('#disconnectRunButton').hide();requestHandlers.push({handler:isComputingSimulation});requestHandlers.push({handler:listGeneratedInstances});callNextRequest();}  )
function requestInstanceSimulation (   h)

Request the instance simulation interaction.

Parameters
hHandler dictionary.
function resetInstance (   h)

Reset an instance from the server.

Suppose that the state is the hash of the instance to delete.

Parameters
hHandler dictionary.
function send (   message)

Send a message through the websocket assuming it is connected.

Parameters
messageMessage to send.
window unload ( function(){disconnect();}  )

Variable Documentation

var disconnectAndRun =false

Instance simulation interaction.

Parameters
hHandler dictionary.
var isHandlerProcessing =false

True if there is an handler prossessing.

var nextHandlers = []

List of dictionaries.

Each dictionary must contain a field "handler" whose value is a function to call.

var POLLING_DELAY =1000

Polling delay in milliseconds.

var requestHandlers =[]

Requests of non started actions.

var server ="ws://139.165.16.33:8000/"

This file contains the javascript client of the engine.

Server adress.

var States ={SENT:0,WAIT:1,RECEIVED:2,GENERATING:3,POLL:4}

Predefined states.

  • SENT : 0
  • WAIT : 1
  • RECEIVED : 2
  • GENERATING : 3
  • POLL : 4
var websocket = null

Current websocket.