mmServerCommunication
Class MMServerComm

java.lang.Object
  extended by mmServerCommunication.MMServerComm

public class MMServerComm
extends java.lang.Object


Nested Class Summary
static class MMServerComm.ClientType
           
 class MMServerComm.MMGetProjectListCallback
           
 
Field Summary
 java.lang.String paramListName
           
 int pollRate
           
 java.lang.String time
           
 java.lang.Long timeInt
           
 long timeOffsetLocalSendTime
           
 
Constructor Summary
MMServerComm(MMAbstractRestAPI restAPI_, MMRestApiUtilAbstract apiUtil, MMStatsAbstract statsParser, MMServerComm.ClientType ct, MMClient c)
           
 
Method Summary
 void addData(java.lang.String userId, int parameterId, int paramType, java.util.HashMap<java.lang.String,java.lang.Object> data)
          Post/set a bunch of parameters to the server.
 void addParameter(java.lang.String paramName, int paramType)
          Add a new parameter in the current project, with an auto-generated unique parameter ID.
 void askForServerTimeOffset()
           
 MMClient getClient()
           
 void getCurrentParamListName()
          Get the last ParamList table name on server and reuse it
 void getMostRecentTime()
          This method gets the time of the most recent data in the ParamList, and sets the time variable Call this method once before polling with the getParameters method.
 MMParam getParameterConfig(int paramId)
          For convenience of getting the current project's parameters/configurations with specified id.
 void getParameters(int paramId, java.lang.Long time)
          Returns a list of parameter objects records with time after the specific time.
 java.util.List<MMParam> getParamsOfCurrentProject()
          For convenience of getting the current project's parameters/configurations.
 MMProject getProject()
          Get the current project.
 int getProjectId()
          Get the ID of the current project.
 java.lang.String getProjectInfo()
           
 void getProjectList(MMServerComm.MMGetProjectListCallback callback)
          Return a list of projects/configurations in the Parse account.
 double getServerTimeOffset()
           
 void getStats(int paramId, int paramType, int window)
          Calls cloud code function to obtain statistics for the given paramId and paramType This function makes a SYNCHRONOUS request so that the next poll will only happen after the previous poll has returned.
 void newProject(java.lang.String projectName)
          Create a new project on the server.
 void pollRaw(int paramId, int pollSwitch, int window)
          Retrieve the raw data for a particular parameter, in a period of history time
 void pollStats(int paramId, int pollSwitch, int window)
          Call the server function to obtain statistics for the given paramId and paramType
 void removeParameter(int paramId)
          Remove a specified parameter from the current project.
 void setClient(MMClient c)
          Set the client instance reference of the communication.
 void setCurrentProject(int projectId, boolean notifyClientWhenDone)
          User enters the project/event, and load the project's properties.
 void setParameter(java.lang.String userId, int parameterId, int paramType, java.util.HashMap<java.lang.String,java.lang.Object> data)
          Post/set a new parameter setting to the server.
 void setPollParams(int paramId, int paramType, java.lang.String dataType)
          Sets the proper parameters to poll for the correct data
 void setPollRate(int pollRate)
          Set the polling rate of the polling timer thread.
 void setProjectInfo(java.lang.String info)
          Set the information text (introduction) of the current active project
 void startAskingTimeOffset()
          Start a backgroud Timer to periodically get the server time, in purpose of sync the time between client and server.
 void startNewParamList()
          Create a new ParamList table in the server dedicated to the current performance session
 void startPolling()
          Start the polling process.
 void stopPolling()
          Stop the polling process.
 void updateProject()
          Commit all local project configuration changes/modifications to the server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

paramListName

public java.lang.String paramListName

time

public java.lang.String time

timeInt

public java.lang.Long timeInt

pollRate

public int pollRate

timeOffsetLocalSendTime

public long timeOffsetLocalSendTime
Constructor Detail

MMServerComm

public MMServerComm(MMAbstractRestAPI restAPI_,
                    MMRestApiUtilAbstract apiUtil,
                    MMStatsAbstract statsParser,
                    MMServerComm.ClientType ct,
                    MMClient c)
Method Detail

getProjectList

public void getProjectList(MMServerComm.MMGetProjectListCallback callback)
Return a list of projects/configurations in the Parse account.


setParameter

public void setParameter(java.lang.String userId,
                         int parameterId,
                         int paramType,
                         java.util.HashMap<java.lang.String,java.lang.Object> data)
Post/set a new parameter setting to the server.

Parameters:
newParam - A parameter of identical properties with one of the parameters in the project, except for some changes in values

addData

public void addData(java.lang.String userId,
                    int parameterId,
                    int paramType,
                    java.util.HashMap<java.lang.String,java.lang.Object> data)
Post/set a bunch of parameters to the server. For e.g., used by Max Client

Parameters:
userId -
paramId -
paramType -
h -

setPollParams

public void setPollParams(int paramId,
                          int paramType,
                          java.lang.String dataType)
Sets the proper parameters to poll for the correct data

Parameters:
currentParamId -
currentParamType -
dataToGet -

setPollRate

public void setPollRate(int pollRate)
Set the polling rate of the polling timer thread.

Parameters:
pollRate -

pollStats

public void pollStats(int paramId,
                      int pollSwitch,
                      int window)
Call the server function to obtain statistics for the given paramId and paramType

Parameters:
paramId -
pollSwitch - turn on/off the polling
window - how long time to look back to, in seconds

pollRaw

public void pollRaw(int paramId,
                    int pollSwitch,
                    int window)
Retrieve the raw data for a particular parameter, in a period of history time

Parameters:
paramId -
pollSwitch - turn on/off the polling
window - how long time to look back to, in seconds

startPolling

public void startPolling()
Start the polling process.


stopPolling

public void stopPolling()
Stop the polling process.


newProject

public void newProject(java.lang.String projectName)
Create a new project on the server.

Parameters:
projectName - The name of the project
Throws:
MMException

setProjectInfo

public void setProjectInfo(java.lang.String info)
Set the information text (introduction) of the current active project

Parameters:
info -

setCurrentProject

public void setCurrentProject(int projectId,
                              boolean notifyClientWhenDone)
User enters the project/event, and load the project's properties.


getProjectInfo

public java.lang.String getProjectInfo()

getParamsOfCurrentProject

public java.util.List<MMParam> getParamsOfCurrentProject()
For convenience of getting the current project's parameters/configurations.


getParameterConfig

public MMParam getParameterConfig(int paramId)
For convenience of getting the current project's parameters/configurations with specified id.


getProject

public MMProject getProject()
Get the current project.

Returns:
the project member.

getMostRecentTime

public void getMostRecentTime()
This method gets the time of the most recent data in the ParamList, and sets the time variable Call this method once before polling with the getParameters method.


startAskingTimeOffset

public void startAskingTimeOffset()
Start a backgroud Timer to periodically get the server time, in purpose of sync the time between client and server. Currently used in GWT client


askForServerTimeOffset

public void askForServerTimeOffset()

getServerTimeOffset

public double getServerTimeOffset()

getProjectId

public int getProjectId()
Get the ID of the current project.

Returns:
the project ID.

getParameters

public void getParameters(int paramId,
                          java.lang.Long time)
Returns a list of parameter objects records with time after the specific time. This function makes a SYNCHRONOUS request so that the next poll will only happen after the previous poll has returned. This should be called in a separate thread.

Parameters:
paramId - The index of the parameter.
time - The time from which to retrieve results, in ISO format.

getStats

public void getStats(int paramId,
                     int paramType,
                     int window)
Calls cloud code function to obtain statistics for the given paramId and paramType This function makes a SYNCHRONOUS request so that the next poll will only happen after the previous poll has returned. This should be called in a separate thread.

Parameters:
paramId -
paramType -
window - (in seconds)

addParameter

public void addParameter(java.lang.String paramName,
                         int paramType)
Add a new parameter in the current project, with an auto-generated unique parameter ID.

Parameters:
paramName - The parameter name of the new parameter
paramType - The parameter type of the new parameter

removeParameter

public void removeParameter(int paramId)
Remove a specified parameter from the current project.

Parameters:
paramId - The parameter ID of the parameter to be removed

updateProject

public void updateProject()
Commit all local project configuration changes/modifications to the server.


getCurrentParamListName

public void getCurrentParamListName()
Get the last ParamList table name on server and reuse it


startNewParamList

public void startNewParamList()
Create a new ParamList table in the server dedicated to the current performance session


setClient

public void setClient(MMClient c)
Set the client instance reference of the communication. This setting is very important.

Parameters:
c - The client instance to be referenced in the communication

getClient

public MMClient getClient()