Skip to content
Snippets Groups Projects
Commit e9a72633 authored by xtof's avatar xtof
Browse files

feat add FXML code and associated java code

parent 0f340a6c
No related branches found
No related tags found
2 merge requests!32Develop,!27Resolve "ECR - UVSQSAT"
......@@ -26,9 +26,26 @@ Each class inherit from a common abstract class **AFrame**
- update parameter.java class with your information
- launch
''maven install''
- launch the application generated
- launch the application is generated
## Code generated
### PoJo
for each definition, generate a class with all data from the packet.
This class can be used for displaying data
### FXML
Generate Gridpane line & column for each instance data
### Controler FXML
Generate textfield parameter with FXML
## Allocate data
Generae a function in order to allocate data data to textfield
......
......@@ -269,12 +269,40 @@ public class GeneratePOJOfromKSY {
// generate display compute data
writer.println(" public String toStringCompute () { \r\n ");
writer.println(" return \" \" ");
/// @todo - vérifier
try {
if( listcomp.size() == list.size() )
{
for (int t = 0; t < listcomp.size(); t++) {
if (formatVariable(listcompraw.get(t))!=null)
{
writer.println("\t + separator + " + "\"" + extractValriableName (listcompraw.get(t)) + " : \" +" + " comp" + upcase(listcomp.get(t)));
writer.println("\t + separator + " + "\"" + extractValriableName (listcompraw.get(t)) + " : Ox\" + toHex("+ list.get(t) + ") + \" : \"+ String.format("+ formatVariable(listcompraw.get(t)) + ", + comp" + upcase(listcomp.get(t))+")");
}else
{
writer.println("\t + separator + " + "\"" + extractValriableName (listcompraw.get(t)) + " : Ox\" + toHex("+ list.get(t) + ") + \" : \" +" + " comp" + upcase(listcomp.get(t)));
}
}
}
else
{
for (int t = 0; t < listcomp.size(); t++)
{
writer.println("\t + separator + " + "\"" + extractValriableName (listcompraw.get(t)) + " : \"+ String.format("+ formatVariable(listcompraw.get(t)) + ", + comp" + upcase(listcomp.get(t))+")");
}
}
} catch (Exception e)
{
System.err.println(e.getMessage());
}
writer.println("; } \r\n");
// generate end file
......@@ -305,8 +333,9 @@ public class GeneratePOJOfromKSY {
}
public String extractValriableName(String in) {
StringBuffer stbuf = new StringBuffer();
in = in.trim();
String var = null;
if (in.endsWith("_raw")){
var = in.substring(0,in.lastIndexOf("_raw"));
......@@ -326,6 +355,7 @@ public class GeneratePOJOfromKSY {
var = in.substring(0,in.lastIndexOf("_c"));
var = var.replace("_", " ");
var = var +" (°C)";
}else if (in.endsWith("_hz"))
{
var = in.substring(0,in.lastIndexOf("_hz"));
......@@ -341,6 +371,11 @@ public class GeneratePOJOfromKSY {
var = in.substring(0,in.lastIndexOf("_v"));
var = var.replace("_", " ");
var = var +" (V)";
}else if (in.endsWith("_mw"))
{
var = in.substring(0,in.lastIndexOf("_mw"));
var = var.replace("_", " ");
var = var +" (mW)";
}else {
var = in.replace("_", " ");
}
......@@ -396,8 +431,18 @@ public class GeneratePOJOfromKSY {
String variable = (String) tablinstance.get(ki);
String variableUp = upcase(variable);
writer.println(" tf"+variableUp+".setText(\"\" + o."+ variableUp + "());");
if (formatVariable(variable)!=null)
{
writer.println(" tf"+variableUp+".setText( String.format("+ formatVariable(variable) + ", o."+variableUp+ "()));");
}else
{
writer.println(" tf"+variableUp+".setText(\"\" + o."+ variableUp + "());");
}
}
......@@ -435,4 +480,29 @@ public class GeneratePOJOfromKSY {
return Character.toUpperCase(line.charAt(0)) + line.substring(1);
}
private String formatVariable (String variable )
{
String format=null;
if (variable.endsWith("_raw"))
{
// nothing
}
else if (variable.endsWith("_byte"))
{
// nothing
}
else if (variable.endsWith("_str"))
{
// Nothing
}else
{
format = "\"%.3f\"";
}
return format;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment