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
NomadCommandSystem
Commits
d396f402
Commit
d396f402
authored
Feb 27, 2017
by
yannick legoc
Browse files
replaced corba generic command box accessor.
parent
633691b0
Changes
5
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
d396f402
...
...
@@ -198,11 +198,6 @@
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/CommandZoneAccessor.idl"
/>
</exec>
<echo
message=
"Generating AtomicCommandBoxAccessor.java"
/>
<exec
executable=
"idl"
>
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/AtomicCommandBoxAccessor.idl"
/>
</exec>
<echo
message=
"Generating ScanCommandBoxAccessor.java"
/>
<exec
executable=
"idl"
>
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/ScanCommandBoxAccessor.idl"
/>
...
...
@@ -213,11 +208,6 @@
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/ForLoopCommandBoxAccessor.idl"
/>
</exec>
<echo
message=
"Generating GenericCommandBoxAccessor.java"
/>
<exec
executable=
"idl"
>
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/GenericCommandBoxAccessor.idl"
/>
</exec>
<echo
message=
"Generating ControlCommandBoxAccessor.java"
/>
<exec
executable=
"idl"
>
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/ControlCommandBoxAccessor.idl"
/>
...
...
src/main/java/fr/ill/ics/nscclient/command/CommandBoxAccessor.java
View file @
d396f402
...
...
@@ -30,12 +30,6 @@ import fr.ill.ics.cameo.RequesterCreationException;
import
fr.ill.ics.nomadserver.commandzone.CommandBoxRequests
;
import
fr.ill.ics.nomadserver.common.Common
;
import
fr.ill.ics.nomadserver.common.Common.Error.Type
;
import
fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.BadCommandBoxTypeException
;
import
fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.BadPropertyTypeException
;
import
fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.CommandBoxNotFoundException
;
import
fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.NoSuchPropertyException
;
import
fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.NullPropertyReferenceException
;
import
fr.ill.ics.nomadserver.core.commandzone.AtomicCommandBoxAccessorPackage.PropertyExpressionSyntaxErrorException
;
import
fr.ill.ics.nscclient.serverconnection.ServerInstance
;
public
class
CommandBoxAccessor
{
...
...
@@ -841,5 +835,220 @@ public class CommandBoxAccessor {
return
""
;
}
public
void
setControllerName
(
int
commandBoxID
,
String
controllerName
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
SetControllerName
)
.
build
();
// Create the request.
CommandBoxRequests
.
SetStringRequest
request
=
CommandBoxRequests
.
SetStringRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
setValue
(
controllerName
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
processError
(
response
.
getError
(),
commandBoxID
);
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"setControllerName"
,
"error in parsing response for command box "
+
commandBoxID
);
}
}
public
String
getControllerName
(
int
commandBoxID
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
GetControllerName
)
.
build
();
// Create the request.
CommandBoxRequests
.
AtomicCommandBoxRequest
request
=
CommandBoxRequests
.
AtomicCommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
StringResponse
response
=
Common
.
StringResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
processError
(
response
.
getError
(),
commandBoxID
);
}
else
{
return
response
.
getValue
();
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"getStringValue"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
null
;
}
public
void
setPropertyName
(
int
commandBoxID
,
String
propertyName
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
SetPropertyName
)
.
build
();
// Create the request.
CommandBoxRequests
.
SetStringRequest
request
=
CommandBoxRequests
.
SetStringRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
setValue
(
propertyName
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
System
.
out
.
println
(
"setPropertyName "
+
commandBoxID
+
" "
+
propertyName
);
// Test the error.
if
(
response
.
hasError
())
{
processError
(
response
.
getError
(),
commandBoxID
);
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"setPropertyName"
,
"error in parsing response for command box "
+
commandBoxID
);
}
}
public
String
getPropertyName
(
int
commandBoxID
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
GetPropertyName
)
.
build
();
// Create the request.
CommandBoxRequests
.
AtomicCommandBoxRequest
request
=
CommandBoxRequests
.
AtomicCommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
StringResponse
response
=
Common
.
StringResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
processError
(
response
.
getError
(),
commandBoxID
);
}
else
{
return
response
.
getValue
();
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"getPropertyName"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
null
;
}
public
int
getBoxType
(
int
commandBoxID
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
GetBoxType
)
.
build
();
// Create the request.
CommandBoxRequests
.
AtomicCommandBoxRequest
request
=
CommandBoxRequests
.
AtomicCommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
Int32Response
response
=
Common
.
Int32Response
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
processError
(
response
.
getError
(),
commandBoxID
);
}
else
{
return
response
.
getValue
();
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"getBoxType"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
0
;
}
public
void
setValue
(
int
commandBoxID
,
String
value
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
SetValue
)
.
build
();
// Create the request.
CommandBoxRequests
.
SetStringRequest
request
=
CommandBoxRequests
.
SetStringRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
setValue
(
value
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
processError
(
response
.
getError
(),
commandBoxID
);
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"setValue"
,
"error in parsing response for command box "
+
commandBoxID
);
}
}
public
String
getValue
(
int
commandBoxID
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
GetValue
)
.
build
();
// Create the request.
CommandBoxRequests
.
AtomicCommandBoxRequest
request
=
CommandBoxRequests
.
AtomicCommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
StringResponse
response
=
Common
.
StringResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
processError
(
response
.
getError
(),
commandBoxID
);
}
else
{
return
response
.
getValue
();
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"getPropertyName"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
null
;
}
}
\ No newline at end of file
src/main/java/fr/ill/ics/nscclient/command/GenericCommandBoxAccessorProxy.java
deleted
100644 → 0
View file @
633691b0
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package
fr.ill.ics.nscclient.command
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
fr.ill.ics.nomadserver.core.commandzone.GenericCommandBoxAccessor
;
import
fr.ill.ics.nomadserver.core.commandzone.GenericCommandBoxAccessorHelper
;
import
fr.ill.ics.nomadserver.core.commandzone.GenericCommandBoxAccessorPackage.BadCommandBoxTypeException
;
import
fr.ill.ics.nomadserver.core.commandzone.GenericCommandBoxAccessorPackage.CommandBoxNotFoundException
;
import
fr.ill.ics.nscclient.corbabase.CorbaNamingService
;
public
class
GenericCommandBoxAccessorProxy
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
GenericCommandBoxAccessorProxy
.
class
.
getName
());
private
String
serverId
;
private
GenericCommandBoxAccessor
genericCommandBoxAccessor
;
private
static
Map
<
String
,
GenericCommandBoxAccessorProxy
>
instances
=
new
HashMap
<
String
,
GenericCommandBoxAccessorProxy
>();
private
GenericCommandBoxAccessorProxy
(
String
serverId
)
{
this
.
serverId
=
serverId
;
}
public
static
GenericCommandBoxAccessorProxy
getInstance
(
String
serverId
)
{
if
(!
instances
.
containsKey
(
serverId
))
{
GenericCommandBoxAccessorProxy
instance
=
new
GenericCommandBoxAccessorProxy
(
serverId
);
instances
.
put
(
serverId
,
instance
);
}
return
instances
.
get
(
serverId
);
}
public
void
init
()
{
try
{
String
contextName
=
"NomadServer"
;
if
(!
serverId
.
equals
(
"real"
))
{
contextName
+=
serverId
;
}
org
.
omg
.
CORBA
.
Object
corbaObj
=
CorbaNamingService
.
getInstance
().
resolveObject
(
contextName
,
"Core"
,
"genericCommandBoxAccessor"
);
genericCommandBoxAccessor
=
GenericCommandBoxAccessorHelper
.
narrow
(
corbaObj
);
}
catch
(
CorbaNamingService
.
CORBAResolveFailureException
rfe
)
{
System
.
err
.
println
(
"Unable to obtain GenericCommandBoxAccessor from Naming Service"
);
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
System
.
err
.
println
(
"Unable to obtain GenericCommandBoxAccessor from Naming Service"
);
}
}
public
void
setControllerName
(
int
commandBoxID
,
String
controllerName
)
{
try
{
genericCommandBoxAccessor
.
setControllerName
(
commandBoxID
,
controllerName
);
}
catch
(
BadCommandBoxTypeException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"BadCommandBoxTypeException occured for GenericCommandBox "
+
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for GenericCommandBox "
+
commandBoxID
);
}
}
public
String
getControllerName
(
int
commandBoxID
)
{
try
{
return
genericCommandBoxAccessor
.
getControllerName
(
commandBoxID
);
}
catch
(
BadCommandBoxTypeException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"BadCommandBoxTypeException occured for GenericCommandBox "
+
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for GenericCommandBox "
+
commandBoxID
);
}
return
null
;
}
public
void
setPropertyName
(
int
commandBoxID
,
String
propertyName
)
{
try
{
genericCommandBoxAccessor
.
setPropertyName
(
commandBoxID
,
propertyName
);
}
catch
(
BadCommandBoxTypeException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"BadCommandBoxTypeException occured for GenericCommandBox "
+
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for GenericCommandBox "
+
commandBoxID
);
}
}
public
String
getPropertyName
(
int
commandBoxID
)
{
try
{
return
genericCommandBoxAccessor
.
getPropertyName
(
commandBoxID
);
}
catch
(
BadCommandBoxTypeException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"BadCommandBoxTypeException occured for GenericCommandBox "
+
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for GenericCommandBox "
+
commandBoxID
);
}
return
null
;
}
public
int
getBoxType
(
int
commandBoxID
)
{
try
{
return
genericCommandBoxAccessor
.
getBoxType
(
commandBoxID
);
}
catch
(
BadCommandBoxTypeException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"BadCommandBoxTypeException occured for GenericCommandBox "
+
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for GenericCommandBox "
+
commandBoxID
);
}
return
0
;
}
public
void
setValue
(
int
commandBoxID
,
String
value
)
{
try
{
genericCommandBoxAccessor
.
setValue
(
commandBoxID
,
value
);
}
catch
(
BadCommandBoxTypeException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"BadCommandBoxTypeException occured for GenericCommandBox "
+
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for GenericCommandBox "
+
commandBoxID
);
}
}
public
String
getValue
(
int
commandBoxID
)
{
try
{
return
genericCommandBoxAccessor
.
getValue
(
commandBoxID
);
}
catch
(
BadCommandBoxTypeException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"BadCommandBoxTypeException occured for GenericCommandBox "
+
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for GenericCommandBox "
+
commandBoxID
);
}
return
null
;
}
}
\ No newline at end of file
src/main/java/fr/ill/ics/nscclient/command/ServerGenericCommandBox.java
View file @
d396f402
...
...
@@ -27,31 +27,31 @@ public class ServerGenericCommandBox extends ServerCommandBox {
}
public
void
setControllerName
(
String
controllerName
)
{
Generic
CommandBoxAccessor
Proxy
.
getInstance
(
serverId
).
setControllerName
(
commandBoxId
,
controllerName
);
CommandBoxAccessor
.
getInstance
(
serverId
).
setControllerName
(
commandBoxId
,
controllerName
);
}
public
String
getControllerName
()
{
return
Generic
CommandBoxAccessor
Proxy
.
getInstance
(
serverId
).
getControllerName
(
commandBoxId
);
return
CommandBoxAccessor
.
getInstance
(
serverId
).
getControllerName
(
commandBoxId
);
}
public
void
setPropertyName
(
String
propertyName
)
{
Generic
CommandBoxAccessor
Proxy
.
getInstance
(
serverId
).
setPropertyName
(
commandBoxId
,
propertyName
);
CommandBoxAccessor
.
getInstance
(
serverId
).
setPropertyName
(
commandBoxId
,
propertyName
);
}
public
String
getPropertyName
()
{
return
Generic
CommandBoxAccessor
Proxy
.
getInstance
(
serverId
).
getPropertyName
(
commandBoxId
);
return
CommandBoxAccessor
.
getInstance
(
serverId
).
getPropertyName
(
commandBoxId
);
}
public
int
getBoxType
()
{
return
Generic
CommandBoxAccessor
Proxy
.
getInstance
(
serverId
).
getBoxType
(
commandBoxId
);
return
CommandBoxAccessor
.
getInstance
(
serverId
).
getBoxType
(
commandBoxId
);
}
public
void
setValue
(
String
value
)
{
Generic
CommandBoxAccessor
Proxy
.
getInstance
(
serverId
).
setValue
(
commandBoxId
,
value
);
CommandBoxAccessor
.
getInstance
(
serverId
).
setValue
(
commandBoxId
,
value
);
}
public
String
getValue
()
{
return
Generic
CommandBoxAccessor
Proxy
.
getInstance
(
serverId
).
getValue
(
commandBoxId
);
return
CommandBoxAccessor
.
getInstance
(
serverId
).
getValue
(
commandBoxId
);
}
public
int
getNumberOfCommandBoxes
()
{
...
...
src/main/java/fr/ill/ics/nscclient/sessionmanagement/ServerSessionManager.java
View file @
d396f402
...
...
@@ -26,11 +26,9 @@ import fr.ill.ics.bridge.ControllerManager;
import
fr.ill.ics.bridge.DriverManager
;
import
fr.ill.ics.bridge.ResourceManager
;
import
fr.ill.ics.nscclient.command.CommandBoxAccessor
;
import
fr.ill.ics.nscclient.command.CommandBoxAccessor
;
import
fr.ill.ics.nscclient.command.CommandZoneAccessorProxy
;
import
fr.ill.ics.nscclient.command.ControlCommandBoxAccessorProxy
;
import
fr.ill.ics.nscclient.command.ForLoopCommandBoxAccessorProxy
;
import
fr.ill.ics.nscclient.command.GenericCommandBoxAccessorProxy
;
import
fr.ill.ics.nscclient.command.ScanCommandBoxAccessorProxy
;
import
fr.ill.ics.nscclient.commandline.CommandLineAccessor
;
import
fr.ill.ics.nscclient.condition.ConditionManagerAccessor
;
...
...
@@ -77,7 +75,6 @@ public class ServerSessionManager {
CommandBoxAccessor
.
getInstance
(
serverId
).
init
();
ScanCommandBoxAccessorProxy
.
getInstance
(
serverId
).
init
();
ForLoopCommandBoxAccessorProxy
.
getInstance
(
serverId
).
init
();
GenericCommandBoxAccessorProxy
.
getInstance
(
serverId
).
init
();
ControlCommandBoxAccessorProxy
.
getInstance
(
serverId
).
init
();
ServerCommandZoneEventManager
.
getInstance
(
serverId
).
init
();
ConditionManagerAccessor
.
getInstance
(
serverId
).
init
();
...
...
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