Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
Protos
Nomad 3D
nomad-3d-commons
Commits
4dcc66fa
Commit
4dcc66fa
authored
Jun 15, 2017
by
Ivan Dages
Browse files
doc & cleanup
parent
bb29ed26
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/ill/ics/n3d/io/Nomad3DExporter.java
View file @
4dcc66fa
...
...
@@ -13,7 +13,6 @@ import javax.xml.transform.stream.StreamResult;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.zeroturnaround.zip.ZipUtil
;
import
fr.ill.ics.n3d.link.Nomad3DController
;
import
fr.ill.ics.n3d.model.Axis
;
...
...
src/main/java/fr/ill/ics/n3d/link/Nomad3DController.java
View file @
4dcc66fa
...
...
@@ -14,7 +14,12 @@ import fr.ill.ics.n3d.model.Component;
*/
public
class
Nomad3DController
{
/**
* Type of the axis of a controller.
* @author dages
*/
public
enum
Type
{
/** Rotation axis. */
ROTATION
{
@Override
public
void
init
()
{
...
...
@@ -24,6 +29,7 @@ public class Nomad3DController {
this
.
unitValues
.
add
(
"degree"
);
}
},
/** Translation axis. */
TRANSLATION
{
@Override
public
void
init
()
{
...
...
@@ -32,6 +38,7 @@ public class Nomad3DController {
this
.
unitValues
.
add
(
"cm"
);
}
},
/** Step controller, unknown axis type. */
STEP
{
@Override
public
void
init
()
{
...
...
@@ -40,14 +47,26 @@ public class Nomad3DController {
}
};
/** Possible representations of the unit of the type. */
protected
ArrayList
<
String
>
unitValues
;
/**
* Default constructor.
*/
private
Type
()
{
init
();
}
/**
* Initialization of the type's unit representations.
*/
protected
abstract
void
init
();
/**
* Conversion of a string to a type.
* @param unitValue Unit representation
* @return The type corresponding to the unit if it exists, null otherwise
*/
public
static
Type
fromUnitValue
(
String
unitValue
)
{
if
(
ROTATION
.
unitValues
.
contains
(
unitValue
))
{
return
Type
.
ROTATION
;
...
...
@@ -61,6 +80,10 @@ public class Nomad3DController {
}
}
/**
* String representation of the type.
* @return First unit representation
*/
@Override
public
String
toString
()
{
return
this
.
unitValues
.
get
(
0
);
...
...
@@ -82,52 +105,102 @@ public class Nomad3DController {
this
.
component
=
null
;
}
/**
* Gets the associated component.
* @return Component if it is set, null otherwise
*/
public
Component
getComponent
()
{
return
component
;
}
/**
* Gets the name of the controller.
* @return The name
*/
public
String
getName
()
{
return
controller
.
getName
();
}
/**
* Gets the value of a property.
* @param propertyName Property name
* @return Value of the property
*/
public
String
getPropertyValue
(
String
propertyName
)
{
Property
prop
=
PropertyManager
.
getInstance
().
getProperty
(
controller
,
propertyName
);
return
prop
.
getValue
();
}
/**
* Gets the server value of a property.
* @param propertyName Property name
* @return Server value of the property
*/
public
String
getPropertyServerValue
(
String
propertyName
)
{
Property
prop
=
PropertyManager
.
getInstance
().
getProperty
(
controller
,
propertyName
);
return
prop
.
getServerValue
();
}
/**
* Gets the server value of the actual position.
* @return The actual position
*/
public
double
getActualPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"actual_position"
));
}
/**
* Gets the server value of the wanted position.
* @return The wanted position
*/
public
double
getWantedPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"wanted_position"
));
}
/**
* Gets the server value of the offset position.
* @return The offset position
*/
public
double
getOffsetPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"offset_position"
));
}
/**
* Gets the server value of the min position.
* @return The min position
*/
public
double
getMinPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"min_position"
));
}
/**
* Gets the server value of the max position.
* @return The max position
*/
public
double
getMaxPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"max_position"
));
}
/**
* Gets the type of the controller, based on the server value of the unit.
* @return The type
*/
public
Type
getType
()
{
return
Type
.
fromUnitValue
(
getPropertyServerValue
(
"unit"
));
}
/**
* Sets the associated component.
* @param component New component
*/
public
void
setComponent
(
Component
component
)
{
this
.
component
=
component
;
}
/**
* String representation of the controller.
* @return Name of the controller
*/
@Override
public
String
toString
()
{
return
this
.
getName
();
...
...
src/main/java/fr/ill/ics/n3d/link/NomadLinker.java
View file @
4dcc66fa
/**
*
*/
package
fr.ill.ics.n3d.link
;
import
java.util.Collection
;
...
...
@@ -8,9 +5,6 @@ import java.util.HashMap;
import
java.util.Set
;
import
java.util.logging.Logger
;
import
org.omg.PortableInterceptor.ServerIdHelper
;
import
fr.ill.ics.bridge.Controller
;
import
fr.ill.ics.bridge.ControllerManager
;
import
fr.ill.ics.bridge.LoginManager
;
import
fr.ill.ics.bridge.LoginManager.ClientAlreadyLaunchedException
;
...
...
@@ -18,7 +12,6 @@ import fr.ill.ics.bridge.LoginManager.ConnectionFailure;
import
fr.ill.ics.bridge.LoginManager.LoginIncorrectException
;
import
fr.ill.ics.bridge.command.CommandZoneWrapper
;
import
fr.ill.ics.cameo.Application
;
import
fr.ill.ics.core.property.Property
;
import
fr.ill.ics.core.property.PropertyManager
;
import
fr.ill.ics.nscclient.servant.ControllerServant
;
import
fr.ill.ics.nscclient.serverconnection.ServerInstance
;
...
...
@@ -26,6 +19,7 @@ import fr.ill.ics.util.ConfigManager;
import
javafx.application.Platform
;
/**
* Class handling the link between the editor and the server.
* @author dages
*/
public
class
NomadLinker
{
...
...
@@ -33,8 +27,10 @@ public class NomadLinker {
public
final
static
int
LOGIN_NOT_OK
=
1
;
public
final
static
int
LOGIN_REFUSED
=
2
;
/** Instance of the linker. */
private
final
static
NomadLinker
instance
=
new
NomadLinker
();
/** Controllers loaded from Nomad server. */
private
HashMap
<
String
,
Nomad3DController
>
controllers
;
/**
...
...
@@ -44,10 +40,18 @@ public class NomadLinker {
controllers
=
new
HashMap
<>();
}
/**
* Gets the instance.
* @return The instance
*/
public
static
NomadLinker
getInstance
()
{
return
instance
;
}
/**
* Initializes the connection to cameo and nomad server.
* @param args Command line arguments of the program
*/
public
void
init
(
String
[]
args
)
{
Logger
.
getLogger
(
"nomad-3d"
).
info
(
"Initializing nomad server connection..."
);
...
...
@@ -76,46 +80,34 @@ public class NomadLinker {
Logger
.
getLogger
(
"nomad-3d"
).
info
(
"Nomad server connection initialized."
);
}
public
Set
<
String
>
getAxisControllersNames
()
{
/**
* Gets the names of the controllers.
* @return Set of controllers names
*/
public
Set
<
String
>
getControllersNames
()
{
return
controllers
.
keySet
();
}
/**
* Gets the controllers.
* @return The controllers
*/
public
Collection
<
Nomad3DController
>
getControllers
()
{
return
this
.
controllers
.
values
();
}
/**
* Gets a specific controller.
* @param name Name of the controller
* @return Specified controller
*/
public
Nomad3DController
getControllerByName
(
String
name
)
{
return
this
.
controllers
.
get
(
name
);
}
// TODO TEST
public
void
displayProperties
()
{
String
msg
=
""
;
String
properties
[]
=
{
"actual_position"
,
"offset_position"
,
"wanted_position"
,
"min_position"
,
"max_position"
,
"unit"
};
msg
+=
"Controllers : \n"
;
for
(
Nomad3DController
controller
:
controllers
.
values
())
{
msg
+=
controller
+
" :\n"
;
// for (String propertyName : properties) {
// String val = controller.getPropertyServerValue(propertyName);
// msg += "\t" + propertyName + " : " + val + "\n";
// }
msg
+=
"\tactual position : "
+
controller
.
getActualPosition
()
+
"\n"
;
msg
+=
"\toffset position : "
+
controller
.
getPropertyServerValue
(
"offset_position"
)
+
"\n"
;
msg
+=
"\twanted position : "
+
controller
.
getWantedPosition
()
+
"\n"
;
msg
+=
"\tmin position : "
+
controller
.
getMinPosition
()
+
"\n"
;
msg
+=
"\tmax position : "
+
controller
.
getMaxPosition
()
+
"\n"
;
msg
+=
"\tunit : "
+
controller
.
getType
()
+
"\n"
;
}
Logger
.
getLogger
(
"nomad-3d"
).
info
(
msg
);
}
/**
* Closes the connection to cameo and nomad server.
*/
public
void
terminate
()
{
Logger
.
getLogger
(
"nomad-3d"
).
info
(
"Terminating nomad server connection..."
);
...
...
@@ -129,7 +121,13 @@ public class NomadLinker {
Logger
.
getLogger
(
"nomad-3d"
).
info
(
"Nomad server connection terminated."
);
}
/**
* Log in nomad server.
* @param login Login
* @param password Password
* @param standalone
* @return Login status
*/
private
int
login
(
String
login
,
String
password
,
boolean
standalone
)
{
int
loginState
=
LOGIN_NOT_OK
;
// Check login and password
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment