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
01941acf
Commit
01941acf
authored
Feb 14, 2017
by
yannick legoc
Browse files
Reimplemented CommandLineProxy Corba classes with Cameo.
parent
58124022
Changes
8
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
01941acf
...
...
@@ -325,12 +325,6 @@
<arg
line=
"${idlFlags} ${idlDataProviderDir}/SurveyPublisher.idl"
/>
</exec>
<!-- command line -->
<echo
message=
"Generating CommandLineProxy.java"
/>
<exec
executable=
"idl"
>
<arg
line=
"${idlFlags} ${idlCoreDir}/commandline/CommandLineProxy.idl"
/>
</exec>
<!-- proto files -->
<echo
message=
"Generating ServantConfiguration.java"
/>
<exec
executable=
"protoc"
>
...
...
@@ -356,6 +350,11 @@
<exec
executable=
"protoc"
>
<arg
line=
"${protoFlags} ${protoDir}/ServantManagerRequests.proto"
/>
</exec>
<echo
message=
"Generating CommandLineRequests.java"
/>
<exec
executable=
"protoc"
>
<arg
line=
"${protoFlags} ${protoDir}/CommandLineRequests.proto"
/>
</exec>
</target>
</configuration>
...
...
src/main/java/fr/ill/ics/bridge/commandline/CommandLineProxyWrapper.java
View file @
01941acf
...
...
@@ -21,7 +21,7 @@ package fr.ill.ics.bridge.commandline;
import
java.util.HashMap
;
import
java.util.Map
;
import
fr.ill.ics.nscclient.commandline.CommandLine
ProxyImpl
;
import
fr.ill.ics.nscclient.commandline.CommandLine
Accessor
;
public
class
CommandLineProxyWrapper
{
...
...
@@ -43,35 +43,35 @@ public class CommandLineProxyWrapper {
}
public
void
executeCommand
(
String
text
)
{
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
executeCommand
(
text
);
CommandLine
Accessor
.
getInstance
(
serverId
).
executeCommand
(
text
);
}
public
void
pauseCommands
()
{
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
pauseCommands
();
CommandLine
Accessor
.
getInstance
(
serverId
).
pauseCommands
();
}
public
void
restartCommands
()
{
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
restartCommands
();
CommandLine
Accessor
.
getInstance
(
serverId
).
restartCommands
();
}
public
void
stopCommands
()
{
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
stopCommands
();
CommandLine
Accessor
.
getInstance
(
serverId
).
stopCommands
();
}
public
void
stopAtEndCommands
()
{
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
stopAtEndCommands
();
CommandLine
Accessor
.
getInstance
(
serverId
).
stopAtEndCommands
();
}
public
boolean
isStarted
()
{
return
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
isStarted
();
return
CommandLine
Accessor
.
getInstance
(
serverId
).
isStarted
();
}
public
boolean
isPaused
()
{
return
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
isPaused
();
return
CommandLine
Accessor
.
getInstance
(
serverId
).
isPaused
();
}
public
void
setCommandLineState
(
boolean
state
)
{
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
setCommandLineState
(
state
);
CommandLine
Accessor
.
getInstance
(
serverId
).
setCommandLineState
(
state
);
}
}
\ No newline at end of file
src/main/java/fr/ill/ics/nscclient/commandline/CommandLineAccessor.java
0 → 100644
View file @
01941acf
/*
* 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.commandline
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
fr.ill.ics.cameo.Application
;
import
fr.ill.ics.cameo.RequesterCreationException
;
import
fr.ill.ics.nomadserver.commandline.CommandLineRequest
;
import
fr.ill.ics.nomadserver.common.Common
;
import
fr.ill.ics.nscclient.serverconnection.ServerInstance
;
public
class
CommandLineAccessor
{
private
static
Map
<
String
,
CommandLineAccessor
>
instances
=
new
HashMap
<
String
,
CommandLineAccessor
>();
private
String
serverId
;
private
Application
.
Requester
commandLineRequester
;
private
CommandLineAccessor
(
String
serverId
)
{
this
.
serverId
=
serverId
;
}
public
static
CommandLineAccessor
getInstance
(
String
serverId
)
{
if
(!
instances
.
containsKey
(
serverId
))
{
CommandLineAccessor
instance
=
new
CommandLineAccessor
(
serverId
);
instances
.
put
(
serverId
,
instance
);
}
return
instances
.
get
(
serverId
);
}
public
void
init
()
{
// Connect nomad server.
Application
.
Instance
nomad
=
ServerInstance
.
getInstance
().
getApplicationInstance
(
serverId
);
if
(
nomad
==
null
)
{
System
.
err
.
println
(
"Problem to connect to the nomad server "
+
serverId
);
return
;
}
System
.
out
.
println
(
"Trying to create command line requester"
);
// Create the requester.
try
{
commandLineRequester
=
Application
.
Requester
.
create
(
nomad
,
"command_line"
);
}
catch
(
RequesterCreationException
e
)
{
System
.
err
.
println
(
"Problem to connect to the command line responder"
);
return
;
}
System
.
out
.
println
(
"Created requester "
+
commandLineRequester
);
}
public
void
reset
()
{
// Terminate the requester.
commandLineRequester
.
terminate
();
}
public
void
executeCommand
(
String
text
)
{
// Create the message type.
CommandLineRequest
.
Message
type
=
CommandLineRequest
.
Message
.
newBuilder
()
.
setType
(
CommandLineRequest
.
Message
.
Type
.
ExecuteCommand
)
.
build
();
// Create the request.
CommandLineRequest
.
CommandRequest
request
=
CommandLineRequest
.
CommandRequest
.
newBuilder
()
.
setText
(
text
)
.
build
();
commandLineRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandLineRequester
.
receive
());
}
catch
(
InvalidProtocolBufferException
e
)
{
System
.
err
.
println
(
"error in parsing response of executeCommand"
);
}
}
public
void
pauseCommands
()
{
// Create the message type.
CommandLineRequest
.
Message
type
=
CommandLineRequest
.
Message
.
newBuilder
()
.
setType
(
CommandLineRequest
.
Message
.
Type
.
PauseCommands
)
.
build
();
// Create the request.
CommandLineRequest
.
EmptyRequest
request
=
CommandLineRequest
.
EmptyRequest
.
newBuilder
()
.
build
();
commandLineRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandLineRequester
.
receive
());
}
catch
(
InvalidProtocolBufferException
e
)
{
System
.
err
.
println
(
"error in parsing response of pauseCommands"
);
}
}
public
void
restartCommands
()
{
// Create the message type.
CommandLineRequest
.
Message
type
=
CommandLineRequest
.
Message
.
newBuilder
()
.
setType
(
CommandLineRequest
.
Message
.
Type
.
RestartCommands
)
.
build
();
// Create the request.
CommandLineRequest
.
EmptyRequest
request
=
CommandLineRequest
.
EmptyRequest
.
newBuilder
()
.
build
();
commandLineRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandLineRequester
.
receive
());
}
catch
(
InvalidProtocolBufferException
e
)
{
System
.
err
.
println
(
"error in parsing response of restartCommands"
);
}
}
public
void
stopCommands
()
{
// Create the message type.
CommandLineRequest
.
Message
type
=
CommandLineRequest
.
Message
.
newBuilder
()
.
setType
(
CommandLineRequest
.
Message
.
Type
.
StopCommands
)
.
build
();
// Create the request.
CommandLineRequest
.
EmptyRequest
request
=
CommandLineRequest
.
EmptyRequest
.
newBuilder
()
.
build
();
commandLineRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandLineRequester
.
receive
());
}
catch
(
InvalidProtocolBufferException
e
)
{
System
.
err
.
println
(
"error in parsing response of stopCommands"
);
}
}
public
void
stopAtEndCommands
()
{
// Create the message type.
CommandLineRequest
.
Message
type
=
CommandLineRequest
.
Message
.
newBuilder
()
.
setType
(
CommandLineRequest
.
Message
.
Type
.
StopAtEndCommands
)
.
build
();
// Create the request.
CommandLineRequest
.
EmptyRequest
request
=
CommandLineRequest
.
EmptyRequest
.
newBuilder
()
.
build
();
commandLineRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandLineRequester
.
receive
());
}
catch
(
InvalidProtocolBufferException
e
)
{
System
.
err
.
println
(
"error in parsing response of stopAtEndCommands"
);
}
}
public
boolean
isStarted
()
{
// Create the message type.
CommandLineRequest
.
Message
type
=
CommandLineRequest
.
Message
.
newBuilder
()
.
setType
(
CommandLineRequest
.
Message
.
Type
.
IsStarted
)
.
build
();
// Create the request.
CommandLineRequest
.
EmptyRequest
request
=
CommandLineRequest
.
EmptyRequest
.
newBuilder
()
.
build
();
commandLineRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandLineRequester
.
receive
());
return
response
.
getValue
();
}
catch
(
InvalidProtocolBufferException
e
)
{
System
.
err
.
println
(
"error in parsing response of isStarted"
);
}
return
false
;
}
public
boolean
isPaused
()
{
// Create the message type.
CommandLineRequest
.
Message
type
=
CommandLineRequest
.
Message
.
newBuilder
()
.
setType
(
CommandLineRequest
.
Message
.
Type
.
IsPaused
)
.
build
();
// Create the request.
CommandLineRequest
.
EmptyRequest
request
=
CommandLineRequest
.
EmptyRequest
.
newBuilder
()
.
build
();
commandLineRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandLineRequester
.
receive
());
return
response
.
getValue
();
}
catch
(
InvalidProtocolBufferException
e
)
{
System
.
err
.
println
(
"error in parsing response of isPaused"
);
}
return
false
;
}
public
void
setCommandLineState
(
boolean
state
)
{
// Create the message type.
CommandLineRequest
.
Message
type
=
CommandLineRequest
.
Message
.
newBuilder
()
.
setType
(
CommandLineRequest
.
Message
.
Type
.
SetCommandLineState
)
.
build
();
// Create the request.
CommandLineRequest
.
CommandLineStateRequest
request
=
CommandLineRequest
.
CommandLineStateRequest
.
newBuilder
()
.
setState
(
state
)
.
build
();
commandLineRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandLineRequester
.
receive
());
}
catch
(
InvalidProtocolBufferException
e
)
{
System
.
err
.
println
(
"error in parsing response of setCommandLineState"
);
}
}
}
\ No newline at end of file
src/main/java/fr/ill/ics/nscclient/commandline/CommandLineProxyImpl.java
deleted
100644 → 0
View file @
58124022
/*
* 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.commandline
;
import
java.util.HashMap
;
import
java.util.Map
;
import
fr.ill.ics.bridge.command.CommandZoneWrapper
;
import
fr.ill.ics.nomadserver.core.commandline.CommandLineProxy
;
import
fr.ill.ics.nomadserver.core.commandline.CommandLineProxyHelper
;
import
fr.ill.ics.nscclient.corbabase.CorbaNamingService
;
public
class
CommandLineProxyImpl
{
private
CommandLineProxy
commandLine
;
private
static
Map
<
String
,
CommandLineProxyImpl
>
instances
=
new
HashMap
<
String
,
CommandLineProxyImpl
>();
private
String
serverId
;
private
CommandLineProxyImpl
(
String
serverId
)
{
this
.
serverId
=
serverId
;
}
public
static
CommandLineProxyImpl
getInstance
(
String
serverId
)
{
if
(!
instances
.
containsKey
(
serverId
))
{
CommandLineProxyImpl
instance
=
new
CommandLineProxyImpl
(
serverId
);
instances
.
put
(
serverId
,
instance
);
}
return
instances
.
get
(
serverId
);
}
public
void
init
()
{
try
{
String
contextName
=
"NomadServer"
;
if
(!
serverId
.
equals
(
CommandZoneWrapper
.
SERVER_ID
))
{
contextName
+=
serverId
;
}
org
.
omg
.
CORBA
.
Object
corbaObj
=
CorbaNamingService
.
getInstance
().
resolveObject
(
contextName
,
"Core"
,
"commandLineProxy"
);
commandLine
=
CommandLineProxyHelper
.
narrow
(
corbaObj
);
}
catch
(
CorbaNamingService
.
CORBAResolveFailureException
rfe
)
{
System
.
err
.
println
(
"Unable to obtain CommandLineProxy from Naming Service"
);
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
System
.
err
.
println
(
"Unable to obtain CommandLineProxy from Naming Service"
);
}
}
public
void
executeCommand
(
String
text
)
{
commandLine
.
executeCommand
(
text
);
}
public
void
pauseCommands
()
{
commandLine
.
pauseCommands
();
}
public
void
restartCommands
()
{
commandLine
.
restartCommands
();
}
public
void
stopCommands
()
{
commandLine
.
stopCommands
();
}
public
void
stopAtEndCommands
()
{
commandLine
.
stopAtEndCommands
();
}
public
boolean
isStarted
()
{
return
commandLine
.
isStarted
();
}
public
boolean
isPaused
()
{
return
commandLine
.
isPaused
();
}
public
void
setCommandLineState
(
boolean
state
)
{
commandLine
.
setCommandLineState
(
state
);
}
}
\ No newline at end of file
src/main/java/fr/ill/ics/nscclient/log/LogSubscriber.java
View file @
01941acf
...
...
@@ -28,18 +28,14 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
fr.ill.ics.bridge.command.CommandZoneWrapper
;
import
fr.ill.ics.bridge.events.ServerLogEvent
;
import
fr.ill.ics.bridge.events.ServerLogEvent.LogLevel
;
import
fr.ill.ics.bridge.listeners.ServerLogEventListener
;
import
fr.ill.ics.bridge.listeners.ServerLogImageDataReadyListener
;
import
fr.ill.ics.bridge.listeners.ServerLogXMLListener
;
import
fr.ill.ics.cameo.Application
;
import
fr.ill.ics.cameo.ConnectionTimeout
;
import
fr.ill.ics.cameo.Server
;
import
fr.ill.ics.nomadserver.notification.NotificationMessage
;
import
fr.ill.ics.nscclient.serverconnection.ServerInstance
;
import
fr.ill.ics.util.ConfigManager
;
public
class
LogSubscriber
{
...
...
src/main/java/fr/ill/ics/nscclient/servant/CorbaControllerManager.java
View file @
01941acf
...
...
@@ -35,7 +35,6 @@ import fr.ill.ics.bridge.listeners.ServerConfigurationChangeListener;
import
fr.ill.ics.nscclient.dataprovider.ServantDatabase
;
import
fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor
;
import
fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor.LoadConfigurationFailure
;
import
fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager
;
import
fr.ill.ics.util.exception.ControllerNotFoundException
;
public
class
CorbaControllerManager
extends
ControllerManager
implements
ServerConfigurationChangeListener
{
...
...
src/main/java/fr/ill/ics/nscclient/servant/CorbaDriverManager.java
View file @
01941acf
...
...
@@ -30,7 +30,6 @@ import java.util.TreeMap;
import
fr.ill.ics.bridge.DriverManager
;
import
fr.ill.ics.nscclient.dataprovider.ServantDatabase
;
import
fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor
;
import
fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager
;
public
class
CorbaDriverManager
extends
DriverManager
{
...
...
src/main/java/fr/ill/ics/nscclient/sessionmanagement/ServerSessionManager.java
View file @
01941acf
...
...
@@ -32,7 +32,7 @@ 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.CommandLine
ProxyImpl
;
import
fr.ill.ics.nscclient.commandline.CommandLine
Accessor
;
import
fr.ill.ics.nscclient.condition.ConditionManagerProxy
;
import
fr.ill.ics.nscclient.dataprovider.DataAccessor
;
import
fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor
;
...
...
@@ -81,7 +81,7 @@ public class ServerSessionManager {
ServerCommandZoneEventManager
.
getInstance
(
serverId
).
init
();
ConditionManagerProxy
.
getInstance
(
serverId
).
init
();
CommandLine
ProxyImpl
.
getInstance
(
serverId
).
init
();
CommandLine
Accessor
.
getInstance
(
serverId
).
init
();
LogSubscriber
.
getInstance
(
serverId
).
init
();
SurveySubcriberImpl
.
getInstance
(
serverId
).
init
();
}
...
...
@@ -156,6 +156,7 @@ public class ServerSessionManager {
DataAccessor
.
getInstance
(
serverId
).
reset
();
ServantManagerAccessor
.
getInstance
(
serverId
).
reset
();
CommandLineAccessor
.
getInstance
(
serverId
).
reset
();
currentSession
.
logout
();
currentSession
=
null
;
...
...
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