Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nomad-3d-commons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Instrument Control
Protos
Nomad 3D
nomad-3d-commons
Commits
5a17ea7a
Commit
5a17ea7a
authored
7 years ago
by
Ivan Dages
Browse files
Options
Downloads
Patches
Plain Diff
link : controller wrapper
parent
688c9e08
Branches
Branches containing commit
Tags
Tags containing commit
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/fr/ill/ics/n3d/link/Nomad3DController.java
+118
-0
118 additions, 0 deletions
src/main/java/fr/ill/ics/n3d/link/Nomad3DController.java
src/main/java/fr/ill/ics/n3d/link/NomadLinker.java
+19
-26
19 additions, 26 deletions
src/main/java/fr/ill/ics/n3d/link/NomadLinker.java
with
137 additions
and
26 deletions
src/main/java/fr/ill/ics/n3d/link/Nomad3DController.java
0 → 100644
+
118
−
0
View file @
5a17ea7a
package
fr.ill.ics.n3d.link
;
import
java.util.ArrayList
;
import
java.util.logging.Logger
;
import
fr.ill.ics.bridge.Controller
;
import
fr.ill.ics.core.property.Property
;
import
fr.ill.ics.core.property.PropertyManager
;
/**
* Wrapper for Nomad controller
* @author dages
*/
public
class
Nomad3DController
{
public
enum
Type
{
ROTATION
{
@Override
public
void
init
()
{
this
.
unitValues
=
new
ArrayList
<
String
>();
this
.
unitValues
.
add
(
""
);
this
.
unitValues
.
add
(
"deg"
);
this
.
unitValues
.
add
(
"degree"
);
}
},
TRANSLATION
{
@Override
public
void
init
()
{
this
.
unitValues
=
new
ArrayList
<
String
>();
this
.
unitValues
.
add
(
"mm"
);
this
.
unitValues
.
add
(
"cm"
);
}
},
STEP
{
@Override
public
void
init
()
{
this
.
unitValues
=
new
ArrayList
<
String
>();
this
.
unitValues
.
add
(
"step"
);
}
};
protected
ArrayList
<
String
>
unitValues
;
private
Type
()
{
init
();
}
protected
abstract
void
init
();
public
static
Type
fromUnitValue
(
String
unitValue
)
{
if
(
ROTATION
.
unitValues
.
contains
(
unitValue
))
{
return
Type
.
ROTATION
;
}
else
if
(
TRANSLATION
.
unitValues
.
contains
(
unitValue
))
{
return
Type
.
TRANSLATION
;
}
else
if
(
STEP
.
unitValues
.
contains
(
unitValue
))
{
return
Type
.
STEP
;
}
else
{
Logger
.
getLogger
(
"nomad-3d"
).
severe
(
"Unknown unit value \""
+
unitValue
+
"\""
);
return
null
;
}
}
@Override
public
String
toString
()
{
return
this
.
unitValues
.
get
(
0
);
}
}
/** Wrapped controller. */
private
Controller
controller
;
/**
* Constructor.
* @param controller Controller to wrap
*/
public
Nomad3DController
(
Controller
controller
)
{
this
.
controller
=
controller
;
}
public
String
getName
()
{
return
controller
.
getName
();
}
public
String
getPropertyValue
(
String
propertyName
)
{
Property
prop
=
PropertyManager
.
getInstance
().
getProperty
(
controller
,
propertyName
);
return
prop
.
getValue
();
}
public
String
getPropertyServerValue
(
String
propertyName
)
{
Property
prop
=
PropertyManager
.
getInstance
().
getProperty
(
controller
,
propertyName
);
return
prop
.
getServerValue
();
}
public
double
getActualPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"actual_position"
));
}
public
double
getWantedPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"wanted_position"
));
}
public
double
getMinPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"min_position"
));
}
public
double
getMaxPosition
()
{
return
Double
.
parseDouble
(
getPropertyServerValue
(
"max_position"
));
}
public
Type
getType
()
{
return
Type
.
fromUnitValue
(
getPropertyServerValue
(
"unit"
));
}
@Override
public
String
toString
()
{
return
this
.
getName
();
}
}
This diff is collapsed.
Click to expand it.
src/main/java/fr/ill/ics/n3d/link/NomadLinker.java
+
19
−
26
View file @
5a17ea7a
...
...
@@ -34,7 +34,7 @@ public class NomadLinker {
private
final
static
NomadLinker
instance
=
new
NomadLinker
();
private
HashMap
<
String
,
Controller
Servant
>
controllers
;
private
HashMap
<
String
,
Nomad3D
Controller
>
controllers
;
/**
* Default constructor.
...
...
@@ -69,12 +69,8 @@ public class NomadLinker {
for
(
String
controllerName
:
controllersNames
)
{
ControllerServant
controller
=
ControllerManager
.
getInstance
().
getController
(
controllerName
);
controllers
.
put
(
controllerName
,
controller
);
// Property prop = PropertyManager.getInstance().getProperty(controller, "actual_position");
// System.out.println("server value : " + prop.getServerValue());
controllers
.
put
(
controllerName
,
new
Nomad3DController
(
controller
));
}
// System.out.println("Loaded controllers : \n" + controllers);
// displayActualPositions();
Logger
.
getLogger
(
"nomad-3d"
).
info
(
"Nomad server connection initialized."
);
}
...
...
@@ -83,35 +79,32 @@ public class NomadLinker {
return
controllers
.
keySet
();
}
public
String
getServerValue
(
String
controllerName
,
String
propertyName
)
{
ControllerServant
controller
=
controllers
.
get
(
controllerName
);
Property
prop
=
PropertyManager
.
getInstance
().
getProperty
(
controller
,
propertyName
);
return
prop
.
getServerValue
();
}
public
String
getValue
(
String
controllerName
,
String
propertyName
)
{
ControllerServant
controller
=
controllers
.
get
(
controllerName
);
Property
prop
=
PropertyManager
.
getInstance
().
getProperty
(
controller
,
propertyName
);
return
prop
.
getValue
();
}
// TODO TEST
private
void
displayActualPositions
()
{
public
void
displayProperties
()
{
String
msg
=
""
;
String
properties
[]
=
{
"actual_position"
,
"offset_position"
,
"wanted_position"
,
"min_position"
,
"max_position"
,
"unit"
};
System
.
out
.
println
(
"Controllers : "
);
for
(
String
controllerName
:
getAxisControllersNames
())
{
System
.
out
.
println
(
controllerName
+
" :"
);
for
(
String
propertyName
:
properties
)
{
String
val
=
getServerValue
(
controllerName
,
propertyName
);
System
.
out
.
println
(
"\t"
+
propertyName
+
" : "
+
val
);
}
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
);
}
public
void
terminate
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment