|
@@ -9,7 +9,7 @@ namespace ErgometerLibrary
|
|
|
{
|
|
{
|
|
|
public class NetCommand
|
|
public class NetCommand
|
|
|
{
|
|
{
|
|
|
- public enum CommandType { LOGIN, DATA, CHAT, LOGOUT, SESSION, VALUESET, USER, RESPONSE, REQUEST, LENGTH, SESSIONDATA, ERROR, BROADCAST }
|
|
|
|
|
|
|
+ public enum CommandType { LOGIN, DATA, CHAT, LOGOUT, SESSION, VALUESET, USER, RESPONSE, REQUEST, LENGTH, SESSIONDATA, ERROR, BROADCAST, UITLEG, PERSONDATA, TESTRESULT}
|
|
|
public enum RequestType { USERS, ALLSESSIONS, OLDDATA, SESSIONDATA, CHAT }
|
|
public enum RequestType { USERS, ALLSESSIONS, OLDDATA, SESSIONDATA, CHAT }
|
|
|
public enum ResponseType { LOGINOK, LOGINWRONG, ERROR, NOTLOGGEDIN }
|
|
public enum ResponseType { LOGINOK, LOGINWRONG, ERROR, NOTLOGGEDIN }
|
|
|
public enum ValueType { TIME, POWER, ENERGY, DISTANCE }
|
|
public enum ValueType { TIME, POWER, ENERGY, DISTANCE }
|
|
@@ -27,9 +27,21 @@ namespace ErgometerLibrary
|
|
|
public bool IsDoctor { get; set; }
|
|
public bool IsDoctor { get; set; }
|
|
|
public string Password { get; set; }
|
|
public string Password { get; set; }
|
|
|
public string ChatMessage { get; set; }
|
|
public string ChatMessage { get; set; }
|
|
|
|
|
+ public string UitlegText { get; set; }
|
|
|
public Meting Meting { get; set; }
|
|
public Meting Meting { get; set; }
|
|
|
public int LengthValue { get; set; }
|
|
public int LengthValue { get; set; }
|
|
|
|
|
|
|
|
|
|
+ public int Gewicht { get; set; }
|
|
|
|
|
+ public int Lengte { get; set; }
|
|
|
|
|
+ public char Geslacht { get; set; }
|
|
|
|
|
+ public int Leeftijd { get; set; }
|
|
|
|
|
+
|
|
|
|
|
+ public double VO2Max { get; set; }
|
|
|
|
|
+ public double MET { get; set; }
|
|
|
|
|
+ public double PopulationAvg { get; set; }
|
|
|
|
|
+ public double ZScore { get; set; }
|
|
|
|
|
+ public string Rating { get; set; }
|
|
|
|
|
+
|
|
|
//SESSION
|
|
//SESSION
|
|
|
public NetCommand(int session)
|
|
public NetCommand(int session)
|
|
|
{
|
|
{
|
|
@@ -38,6 +50,27 @@ namespace ErgometerLibrary
|
|
|
Timestamp = Helper.Now;
|
|
Timestamp = Helper.Now;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //PERSONDATA
|
|
|
|
|
+ public NetCommand(int gewicht, int lengte, int leeftijd, char geslacht, int session)
|
|
|
|
|
+ {
|
|
|
|
|
+ Type = CommandType.PERSONDATA;
|
|
|
|
|
+ Session = session;
|
|
|
|
|
+ Timestamp = Helper.Now;
|
|
|
|
|
+
|
|
|
|
|
+ Gewicht = gewicht;
|
|
|
|
|
+ Lengte = lengte;
|
|
|
|
|
+ Leeftijd = leeftijd;
|
|
|
|
|
+ Geslacht = geslacht;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //UITLEG
|
|
|
|
|
+ public NetCommand(int session, string uitlegtext)
|
|
|
|
|
+ {
|
|
|
|
|
+ Type = CommandType.UITLEG;
|
|
|
|
|
+ Session = session;
|
|
|
|
|
+ Timestamp = Helper.Now;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//SESSIONDATA
|
|
//SESSIONDATA
|
|
|
public NetCommand(string name, double timestamp, int session)
|
|
public NetCommand(string name, double timestamp, int session)
|
|
|
{
|
|
{
|
|
@@ -196,11 +229,35 @@ namespace ErgometerLibrary
|
|
|
return ParseSessionData(session, args);
|
|
return ParseSessionData(session, args);
|
|
|
case 12:
|
|
case 12:
|
|
|
return ParseBroadcast(session, args);
|
|
return ParseBroadcast(session, args);
|
|
|
|
|
+ case 13:
|
|
|
|
|
+ return ParseUitleg(session, args);
|
|
|
|
|
+ case 14:
|
|
|
|
|
+ return ParsePersonData(session, args);
|
|
|
default:
|
|
default:
|
|
|
throw new FormatException("Error in NetCommand: " + comType + " is not a valid command type.");
|
|
throw new FormatException("Error in NetCommand: " + comType + " is not a valid command type.");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static NetCommand ParsePersonData(int session, string[] args)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (args.Length != 4)
|
|
|
|
|
+ throw new MissingFieldException("Error in NetCommand: PersonData is missing arguments");
|
|
|
|
|
+
|
|
|
|
|
+ NetCommand temp = new NetCommand(int.Parse(args[0]), int.Parse(args[1]), int.Parse(args[2]), char.Parse(args[3]), session);
|
|
|
|
|
+
|
|
|
|
|
+ return temp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static NetCommand ParseUitleg(int session, string[] args)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (args.Length != 1)
|
|
|
|
|
+ throw new MissingFieldException("Error in NetCommand: Uitleg is missing arguments");
|
|
|
|
|
+
|
|
|
|
|
+ NetCommand temp = new NetCommand(session, args[0].Replace('«', '\n'));
|
|
|
|
|
+
|
|
|
|
|
+ return temp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static NetCommand ParseBroadcast(int session, string[] args)
|
|
private static NetCommand ParseBroadcast(int session, string[] args)
|
|
|
{
|
|
{
|
|
|
if (args.Length != 1)
|
|
if (args.Length != 1)
|
|
@@ -410,6 +467,12 @@ namespace ErgometerLibrary
|
|
|
case CommandType.BROADCAST:
|
|
case CommandType.BROADCAST:
|
|
|
command += "12»ses" + Session + "»" + ChatMessage;
|
|
command += "12»ses" + Session + "»" + ChatMessage;
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case CommandType.UITLEG:
|
|
|
|
|
+ command += "13»ses" + Session + "»" + UitlegText.Replace('\n', '«');
|
|
|
|
|
+ break;
|
|
|
|
|
+ case CommandType.PERSONDATA:
|
|
|
|
|
+ command += "13»ses" + Session + "»" + Gewicht + "»" + Lengte + "»" + Leeftijd + "»" + Geslacht;
|
|
|
|
|
+ break;
|
|
|
case CommandType.ERROR:
|
|
case CommandType.ERROR:
|
|
|
command += "ERROR IN NETCOMMAND";
|
|
command += "ERROR IN NETCOMMAND";
|
|
|
break;
|
|
break;
|