Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
NomadCommandSystem
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Instrument Control
NomadCommandSystem
Commits
296ec324
Commit
296ec324
authored
Jan 28, 2019
by
ics
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch variable into master
parent
a3350ce9
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1544 additions
and
430 deletions
+1544
-430
ChangeLog
ChangeLog
+0
-1
pom.xml
pom.xml
+6
-1
src/main/java/fr/ill/ics/bridge/ControllerManager.java
src/main/java/fr/ill/ics/bridge/ControllerManager.java
+60
-51
src/main/java/fr/ill/ics/bridge/events/ServerVariableStateChangeEvent.java
...ill/ics/bridge/events/ServerVariableStateChangeEvent.java
+59
-0
src/main/java/fr/ill/ics/bridge/events/ServerVariableValueChangeEvent.java
...ill/ics/bridge/events/ServerVariableValueChangeEvent.java
+51
-0
src/main/java/fr/ill/ics/bridge/listeners/ServerConfigurationChangeListener.java
...s/bridge/listeners/ServerConfigurationChangeListener.java
+2
-2
src/main/java/fr/ill/ics/bridge/listeners/ServerVariableValueChangeListener.java
...s/bridge/listeners/ServerVariableValueChangeListener.java
+35
-0
src/main/java/fr/ill/ics/core/property/ArrayProperty.java
src/main/java/fr/ill/ics/core/property/ArrayProperty.java
+21
-7
src/main/java/fr/ill/ics/core/property/BooleanProperty.java
src/main/java/fr/ill/ics/core/property/BooleanProperty.java
+22
-30
src/main/java/fr/ill/ics/core/property/Float64Property.java
src/main/java/fr/ill/ics/core/property/Float64Property.java
+16
-34
src/main/java/fr/ill/ics/core/property/Int32Property.java
src/main/java/fr/ill/ics/core/property/Int32Property.java
+16
-29
src/main/java/fr/ill/ics/core/property/Property.java
src/main/java/fr/ill/ics/core/property/Property.java
+241
-45
src/main/java/fr/ill/ics/core/property/PropertyFactory.java
src/main/java/fr/ill/ics/core/property/PropertyFactory.java
+4
-45
src/main/java/fr/ill/ics/core/property/PropertyManager.java
src/main/java/fr/ill/ics/core/property/PropertyManager.java
+61
-92
src/main/java/fr/ill/ics/core/property/StringProperty.java
src/main/java/fr/ill/ics/core/property/StringProperty.java
+49
-23
src/main/java/fr/ill/ics/core/property/condition/RangePropertyDependentCondition.java
...e/property/condition/RangePropertyDependentCondition.java
+4
-0
src/main/java/fr/ill/ics/core/property/format/DecimalFormat.java
...n/java/fr/ill/ics/core/property/format/DecimalFormat.java
+4
-4
src/main/java/fr/ill/ics/core/property/format/HexadecimalFormat.java
...va/fr/ill/ics/core/property/format/HexadecimalFormat.java
+1
-1
src/main/java/fr/ill/ics/core/property/undo/AutoApplyState.java
...in/java/fr/ill/ics/core/property/undo/AutoApplyState.java
+15
-1
src/main/java/fr/ill/ics/core/property/undo/UndoArrayState.java
...in/java/fr/ill/ics/core/property/undo/UndoArrayState.java
+11
-0
src/main/java/fr/ill/ics/core/property/undo/UndoState.java
src/main/java/fr/ill/ics/core/property/undo/UndoState.java
+47
-6
src/main/java/fr/ill/ics/core/property/undo/UndoableState.java
...ain/java/fr/ill/ics/core/property/undo/UndoableState.java
+26
-3
src/main/java/fr/ill/ics/nscclient/command/CommandZoneAccessor.java
...ava/fr/ill/ics/nscclient/command/CommandZoneAccessor.java
+320
-16
src/main/java/fr/ill/ics/nscclient/command/ServerControlCommandBox.java
...fr/ill/ics/nscclient/command/ServerControlCommandBox.java
+9
-1
src/main/java/fr/ill/ics/nscclient/condition/ConditionManagerAccessor.java
...ill/ics/nscclient/condition/ConditionManagerAccessor.java
+1
-1
src/main/java/fr/ill/ics/nscclient/dataprovider/DataAccessor.java
.../java/fr/ill/ics/nscclient/dataprovider/DataAccessor.java
+1
-1
src/main/java/fr/ill/ics/nscclient/dataprovider/ServantDatabase.java
...va/fr/ill/ics/nscclient/dataprovider/ServantDatabase.java
+5
-5
src/main/java/fr/ill/ics/nscclient/notification/ConfigurationChangedNotificationData.java
...nt/notification/ConfigurationChangedNotificationData.java
+7
-7
src/main/java/fr/ill/ics/nscclient/notification/DataChangeSubscriber.java
.../ill/ics/nscclient/notification/DataChangeSubscriber.java
+34
-10
src/main/java/fr/ill/ics/nscclient/notification/DataNotificationClient.java
...ll/ics/nscclient/notification/DataNotificationClient.java
+64
-12
src/main/java/fr/ill/ics/nscclient/sessionmanagement/ServerSessionManager.java
...ics/nscclient/sessionmanagement/ServerSessionManager.java
+4
-1
src/main/java/fr/ill/ics/nscclient/variable/VariableManagerAccessor.java
...r/ill/ics/nscclient/variable/VariableManagerAccessor.java
+347
-0
src/main/java/fr/ill/ics/util/exception/PropertyNotFoundException.java
.../fr/ill/ics/util/exception/PropertyNotFoundException.java
+1
-1
No files found.
ChangeLog
View file @
296ec324
...
...
@@ -13,7 +13,6 @@
-----
* Modifications for dynamic properties management.
3.1.6 06/04/2018
-----
* Added more control on the subscriber termination in survey.
...
...
pom.xml
View file @
296ec324
...
...
@@ -2,7 +2,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
fr.ill.ics
</groupId>
<artifactId>
nomadcommandsystem
</artifactId>
<version>
3.
1.9
</version>
<version>
3.
2.0-SNAPSHOT
</version>
<name>
NomadCommandSystem
</name>
<description>
Java bridge for the communication with the Nomad server
</description>
<scm>
...
...
@@ -170,6 +170,11 @@
<arg
line=
"${protoFlags} ${protoDir}/CommandLineRequests.proto"
/>
</exec>
<echo
message=
"Generating VariableManagerRequests.java"
/>
<exec
executable=
"protoc"
>
<arg
line=
"${protoFlags} ${protoDir}/VariableManagerRequests.proto"
/>
</exec>
<echo
message=
"Generating ConditionManagerRequests.java"
/>
<exec
executable=
"protoc"
>
<arg
line=
"${protoFlags} ${protoDir}/ConditionManagerRequests.proto"
/>
...
...
src/main/java/fr/ill/ics/bridge/ControllerManager.java
View file @
296ec324
...
...
@@ -41,30 +41,30 @@ import fr.ill.ics.util.exception.ControllerNotFoundException;
public
class
ControllerManager
implements
ServerConfigurationChangeListener
{
private
String
serverId
;
private
HashMap
<
String
,
LinkedHashSet
<
String
>>
visibleControllerNamesByType
;
// KEY=controller type VALUE=list of matching controller names
private
HashMap
<
String
,
LinkedHashSet
<
String
>>
allControllerNamesByType
;
// KEY=controller type VALUE=list of matching controller names
private
static
ControllerManager
instance
=
null
;
public
static
ControllerManager
getInstance
()
{
return
instance
;
}
public
static
void
initInstance
(
String
serverId
)
{
instance
=
new
ControllerManager
(
serverId
);
instance
.
init
();
}
public
static
void
resetInstance
()
{
instance
=
null
;
}
public
static
ControllerManager
getInstance
()
{
return
instance
;
}
public
static
void
initInstance
(
String
serverId
)
{
instance
=
new
ControllerManager
(
serverId
);
instance
.
init
();
}
public
static
void
resetInstance
()
{
instance
=
null
;
}
public
void
addConfigurationChangeListener
(
ServerConfigurationChangeListener
listener
)
{
DataNotificationClient
.
getInstance
().
addConfigurationChangeListener
(
listener
);
}
public
ControllerManager
(
String
serverId
)
{
this
.
serverId
=
serverId
;
...
...
@@ -81,7 +81,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
protected
void
reset
()
{
try
{
ServantManagerAccessor
.
getInstance
(
serverId
).
updateWholeConfiguration
();
}
catch
(
LoadConfigurationFailure
e
)
{
System
.
err
.
println
(
"Unable to update the whole configuration"
);
}
...
...
@@ -92,16 +92,17 @@ public class ControllerManager implements ServerConfigurationChangeListener {
/**
*
*/
public
ControllerServant
getController
(
String
controllerName
)
{
public
ControllerServant
getController
(
String
controllerName
)
throws
ControllerNotFoundException
{
ClientServantDescriptor
descriptor
=
ServantDatabase
.
getInstance
().
getControllerDescriptor
(
controllerName
);
if
(
descriptor
!=
null
)
{
ControllerServant
controller
=
ServantManagerAccessor
.
getInstance
(
serverId
).
getController
(
descriptor
);
return
controller
;
}
ControllerNotFoundException
cnfe
=
new
ControllerNotFoundException
(
controllerName
,
""
,
getClass
().
getCanonicalName
(),
"getController"
);
return
null
;
throw
cnfe
;
}
public
ControllerServant
cloneController
(
String
controllerName
)
throws
ControllerNotFoundException
{
ClientServantDescriptor
descriptor
=
ServantDatabase
.
getInstance
().
getControllerDescriptor
(
controllerName
);
if
(
descriptor
!=
null
)
{
...
...
@@ -126,8 +127,8 @@ public class ControllerManager implements ServerConfigurationChangeListener {
public
Set
<
String
>
getControllersOfType
(
String
type
,
boolean
onlyVisibleOnes
)
{
return
ServantDatabase
.
getInstance
().
getControllersOfType
(
type
,
onlyVisibleOnes
);
}
public
Set
<
String
>
getControllerTypes
()
{
return
ServantDatabase
.
getInstance
().
getControllerTypes
();
}
...
...
@@ -142,7 +143,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
return
ServantManagerAccessor
.
getInstance
(
serverId
).
getPropertiesForGeneric
();
}
public
String
getType
(
String
controllerName
)
{
ClientServantDescriptor
descriptor
=
ServantDatabase
.
getInstance
().
getControllerDescriptor
(
controllerName
);
if
(
descriptor
!=
null
)
{
...
...
@@ -150,26 +151,26 @@ public class ControllerManager implements ServerConfigurationChangeListener {
}
return
null
;
}
private
Map
<
String
,
Map
<
String
,
List
<
String
>>>
getInstalledControllers
(
boolean
testCommand
)
{
Map
<
String
,
Map
<
String
,
List
<
String
>>>
installedControllers
=
new
TreeMap
<
String
,
Map
<
String
,
List
<
String
>>>();
Iterator
<
ClientServantDescriptor
>
it
=
ServantDatabase
.
getInstance
().
getControllers
().
iterator
();
while
(
it
.
hasNext
())
{
ClientServantDescriptor
descriptor
=
it
.
next
();
boolean
testCommandOk
=
true
;
if
(
testCommand
&&
!
descriptor
.
isCommand
())
{
testCommandOk
=
false
;
}
if
(
testCommandOk
&&
descriptor
.
isEnabled
()
&&
descriptor
.
isVisible
())
{
String
family
=
descriptor
.
getFamily
();
String
subfamily
=
descriptor
.
getSubfamily
();
Map
<
String
,
List
<
String
>>
familyMembers
=
installedControllers
.
get
(
family
);
if
(
familyMembers
==
null
)
{
familyMembers
=
new
TreeMap
<
String
,
List
<
String
>>();
...
...
@@ -177,23 +178,23 @@ public class ControllerManager implements ServerConfigurationChangeListener {
}
if
(
subfamily
.
equals
(
"none"
))
{
familyMembers
.
put
(
descriptor
.
getName
(),
new
ArrayList
<
String
>());
}
else
{
List
<
String
>
subfamilyMembers
=
familyMembers
.
get
(
subfamily
);
if
(
subfamilyMembers
==
null
)
{
subfamilyMembers
=
new
ArrayList
<
String
>();
familyMembers
.
put
(
subfamily
,
subfamilyMembers
);
}
subfamilyMembers
.
add
(
descriptor
.
getName
());
}
}
}
return
installedControllers
;
}
...
...
@@ -201,7 +202,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
public
Map
<
String
,
Map
<
String
,
List
<
String
>>>
getInstalledControllers
()
{
return
getInstalledControllers
(
false
);
}
public
Map
<
String
,
Map
<
String
,
List
<
String
>>>
getInstalledCommands
()
{
return
getInstalledControllers
(
true
);
}
...
...
@@ -246,13 +247,17 @@ public class ControllerManager implements ServerConfigurationChangeListener {
public
Set
getStartedControllers
()
{
Set
startedCommands
=
new
HashSet
();
Iterator
<
ClientServantDescriptor
>
it
=
ServantDatabase
.
getInstance
().
getControllers
().
iterator
();
while
(
it
.
hasNext
())
{
ClientServantDescriptor
descriptor
=
it
.
next
();
ControllerServant
controller
=
getController
(
descriptor
.
getName
());
if
(
controller
.
isStarted
())
{
startedCommands
.
add
(
controller
);
try
{
Iterator
<
ClientServantDescriptor
>
it
=
ServantDatabase
.
getInstance
().
getControllers
().
iterator
();
while
(
it
.
hasNext
())
{
ClientServantDescriptor
descriptor
=
it
.
next
();
ControllerServant
controller
=
getController
(
descriptor
.
getName
());
if
(
controller
.
isStarted
())
{
startedCommands
.
add
(
controller
);
}
}
}
catch
(
ControllerNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
startedCommands
;
}
...
...
@@ -278,7 +283,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
}
return
null
;
}
public
String
getSubfamily
(
String
controllerName
)
{
ClientServantDescriptor
descriptor
=
ServantDatabase
.
getInstance
().
getControllerDescriptor
(
controllerName
);
if
(
descriptor
!=
null
)
{
...
...
@@ -302,13 +307,17 @@ public class ControllerManager implements ServerConfigurationChangeListener {
}
public
void
configurationChanged
(
int
servantID
,
ClientEnableState
enable
)
{
// the reload of controllers is not made here but in the CommandsSelectionPlugin
// and SettingsSelectionPlugin classes
ServantManagerAccessor
.
getInstance
(
serverId
).
updateDynamicProperties
(
servantID
);
public
void
configurationChanged
(
int
servantID
,
ClientConfigurationState
enable
)
{
// The reloading of controllers is not made here but in the CommandsSelectionPlugin
// and SettingsSelectionPlugin classes.
if
(
enable
==
ClientConfigurationState
.
PROPERTY
)
{
ServantManagerAccessor
.
getInstance
(
serverId
).
updateDynamicProperties
(
servantID
);
System
.
out
.
println
(
"ServantManagerAccessor updateDynamicProperties "
+
servantID
);
}
}
public
void
reloadControllers
()
{
// reset controller information
reset
();
...
...
@@ -318,11 +327,11 @@ public class ControllerManager implements ServerConfigurationChangeListener {
ControllerServant
controller
=
(
ControllerServant
)
servant
;
return
ServantManagerAccessor
.
getInstance
(
serverId
).
getControllerNameWithRole
(
controller
.
getId
(),
role
);
}
public
HashMap
<
String
,
String
>
getServantPropertiesValue
(
int
databaseID
,
int
servantID
)
{
return
ServantManagerAccessor
.
getInstance
(
serverId
).
getServantPropertiesValue
(
databaseID
,
servantID
);
}
public
HashMap
<
String
,
Integer
>
getServantCommandStates
(
int
databaseID
,
int
servantID
)
{
return
ServantManagerAccessor
.
getInstance
(
serverId
).
getServantCommandStates
(
databaseID
,
servantID
);
}
...
...
src/main/java/fr/ill/ics/bridge/events/ServerVariableStateChangeEvent.java
0 → 100644
View file @
296ec324
/*
* 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.bridge.events
;
/**
*
* @author ortizh
*
*/
public
class
ServerVariableStateChangeEvent
{
private
String
variableName
;
private
VariableState
state
;
public
enum
VariableState
{
DISABLED
,
ENABLED
}
public
ServerVariableStateChangeEvent
(
String
variableName
)
{
this
.
variableName
=
variableName
;
}
public
String
getVariableName
()
{
return
variableName
;
}
public
void
setVariableName
(
String
variableName
)
{
this
.
variableName
=
variableName
;
}
public
VariableState
getState
()
{
return
state
;
}
public
void
setState
(
VariableState
state
)
{
this
.
state
=
state
;
};
public
boolean
isEnabled
()
{
return
(
state
==
VariableState
.
ENABLED
);
}
public
boolean
isDisabled
()
{
return
(
state
==
VariableState
.
DISABLED
);
}
}
src/main/java/fr/ill/ics/bridge/events/ServerVariableValueChangeEvent.java
0 → 100644
View file @
296ec324
/*
* 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.bridge.events
;
/**
*
* @author ortizh
*
*/
public
class
ServerVariableValueChangeEvent
{
private
String
variableName
;
private
double
variableValue
;
public
ServerVariableValueChangeEvent
(
String
variableName
,
double
variableValue
)
{
this
.
variableName
=
variableName
;
this
.
variableValue
=
variableValue
;
}
public
String
getVariableName
()
{
return
variableName
;
}
public
void
setVariableName
(
String
variableName
)
{
this
.
variableName
=
variableName
;
}
public
double
getVariableValue
()
{
return
variableValue
;
}
public
void
setVariableValue
(
double
variableValue
)
{
this
.
variableValue
=
variableValue
;
}
}
src/main/java/fr/ill/ics/bridge/listeners/ServerConfigurationChangeListener.java
View file @
296ec324
...
...
@@ -21,8 +21,8 @@ package fr.ill.ics.bridge.listeners;
public
interface
ServerConfigurationChangeListener
{
public
enum
Client
EnableState
{
ENABLED
,
DISABLED
,
NO_CHANGE
};
public
enum
Client
ConfigurationState
{
ENABLED
,
DISABLED
,
TREE
,
PROPERTY
};
void
configurationChanged
(
int
servantID
,
Client
Enable
State
enable
);
void
configurationChanged
(
int
servantID
,
Client
Configuration
State
enable
);
}
\ No newline at end of file
src/main/java/fr/ill/ics/bridge/listeners/ServerVariableValueChangeListener.java
0 → 100644
View file @
296ec324
/*
* 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.bridge.listeners
;
import
fr.ill.ics.bridge.events.ServerVariableStateChangeEvent
;
import
fr.ill.ics.bridge.events.ServerVariableValueChangeEvent
;
/**
*
* @author ortizh
*
*/
public
interface
ServerVariableValueChangeListener
{
public
void
variableValueChanged
(
ServerVariableValueChangeEvent
variableValueChangeEvent
);
public
void
variableStateChanged
(
ServerVariableStateChangeEvent
variableStateChangeEvent
);
}
\ No newline at end of file
src/main/java/fr/ill/ics/core/property/ArrayProperty.java
View file @
296ec324
...
...
@@ -58,6 +58,10 @@ public abstract class ArrayProperty extends Property {
}
}
}
public
boolean
isConstant
(
String
value
)
{
return
true
;
}
/**
* For array properties the getServerValue has no meaning and shouldn't be used.
...
...
@@ -67,12 +71,20 @@ public abstract class ArrayProperty extends Property {
public
String
getServerValue
()
{
return
"Array Property"
;
}
public
GetExpressionResult
getServerExpression
()
{
return
new
GetExpressionResult
(
"Array Expression"
,
ExpressionStatus
.
VALID_CONSTANT
);
}
public
ExpressionResult
checkServerValue
(
String
value
)
{
return
new
ExpressionResult
(
ExpressionStatus
.
VALID_CONSTANT
);
}
/**
* SetServerValue has no meaning for array properties. Do nothing.
*/
public
boolean
setServerValue
(
String
value
)
{
return
true
;
public
ExpressionResult
setServerValue
(
String
value
)
{
return
new
ExpressionResult
(
ExpressionStatus
.
VALID_CONSTANT
)
;
}
/**
...
...
@@ -141,11 +153,13 @@ public abstract class ArrayProperty extends Property {
return
100
;
}
public
Property
cloneAsString
(
boolean
isTrueString
)
{
// don't clone array as string
return
this
;
@Override
protected
String
getPropertyValueFromDatabase
()
{
return
"array"
;
}
protected
boolean
setPropertyValueInDatabase
(
String
value
)
{
return
false
;
}
public
abstract
float
getMinValue
();
...
...
src/main/java/fr/ill/ics/core/property/BooleanProperty.java
View file @
296ec324
...
...
@@ -18,7 +18,6 @@
package
fr.ill.ics.core.property
;
import
fr.ill.ics.nscclient.command.CommandZoneAccessor
;
import
fr.ill.ics.nscclient.dataprovider.DataAccessor
;
public
class
BooleanProperty
extends
Property
{
...
...
@@ -27,38 +26,21 @@ public class BooleanProperty extends Property {
super
(
containerId
,
id
,
isCommandBox
);
}
public
void
setPVerifyListener
()
{
}
public
String
getServerValue
()
{
// Don't use format for the moment. The value can only be "true" or "false"
if
(
isCommandBox
)
{
return
Boolean
.
toString
(
CommandZoneAccessor
.
getInstance
(
serverId
).
getBooleanValue
(
containerId
,
id
));
}
else
{
return
Boolean
.
toString
(
DataAccessor
.
getInstance
(
serverId
).
getBooleanValue
(
containerId
,
id
));
public
boolean
isConstant
(
String
value
)
{
try
{
Boolean
.
parseBoolean
(
value
);
return
true
;
}
}
public
boolean
setServerValue
(
String
value
)
{
// don't check value matches conditions: we only have a choice of "true" or "false"
//try {
boolean
ok
=
true
;
if
(
isCommandBox
)
{
ok
=
CommandZoneAccessor
.
getInstance
(
serverId
).
setBooleanValue
(
containerId
,
id
,
Boolean
.
valueOf
(
value
).
booleanValue
());
}
else
{
ok
=
DataAccessor
.
getInstance
(
serverId
).
setBooleanValue
(
containerId
,
id
,
Boolean
.
valueOf
(
value
).
booleanValue
());
if
(!
ok
)
{
sendPropertyChangedEvent
();
}
catch
(
NumberFormatException
e
)
{
return
false
;
}
showSettingPropertyMessage
(
value
);
return
ok
;
//} catch (CannotSetValueException e) {
// // if the value is refused then update all widgets with the true value.
// sendPropertyChangedEvent();
//}
}
public
void
setPVerifyListener
()
{
}
public
boolean
propertyAcceptsValue
(
String
value
,
boolean
isFinalValue
)
{
if
(
value
.
trim
().
toLowerCase
().
equals
(
"true"
)
||
value
.
trim
().
toLowerCase
().
equals
(
"false"
))
{
return
true
;
...
...
@@ -78,4 +60,14 @@ public class BooleanProperty extends Property {
public
String
getType
()
{
return
"boolean"
;
}
@Override
protected
String
getPropertyValueFromDatabase
()
{
return
Boolean
.
toString
(
DataAccessor
.
getInstance
(
serverId
).
getBooleanValue
(
containerId
,
id
));
}
@Override
protected
boolean
setPropertyValueInDatabase
(
String
value
)
{
return
DataAccessor
.
getInstance
(
serverId
).
setBooleanValue
(
containerId
,
id
,
Boolean
.
valueOf
(
this
.
propertyFormat
.
unformat
(
value
)).
booleanValue
());
}
}
\ No newline at end of file
src/main/java/fr/ill/ics/core/property/Float64Property.java
View file @
296ec324
...
...
@@ -18,9 +18,7 @@
package
fr.ill.ics.core.property
;
import
fr.ill.ics.nscclient.command.CommandZoneAccessor
;
import
fr.ill.ics.nscclient.dataprovider.DataAccessor
;
import
fr.ill.ics.util.ConfigManager
;
public
class
Float64Property
extends
FloatProperty
{
...
...
@@ -28,44 +26,28 @@ public class Float64Property extends FloatProperty {
super
(
containerId
,
id
,
isCommandBox
);
}
public
String
getServerValue
()
{
try
{
if
(
isCommandBox
)
{
return
this
.
propertyFormat
.
formatForDisplay
(
Double
.
valueOf
(
CommandZoneAccessor
.
getInstance
(
serverId
).
getFloat64Value
(
containerId
,
id
)).
toString
());
}
else
{
return
this
.
propertyFormat
.
formatForDisplay
(
Double
.
valueOf
(
DataAccessor
.
getInstance
(
serverId
).
getFloat64Value
(
containerId
,
id
)).
toString
());
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Exception while getting value for property "
+
getName
());
ConfigManager
.
CONFIGURATION_ERROR
=
true
;
return
""
;
}
}
public
boolean
isConstant
(
String
value
)
{
public
boolean
setServerValue
(
String
value
)
{
try
{
String
serverValue
=
this
.
propertyFormat
.
unformat
(
value
);
boolean
ok
=
isOk
(
serverValue
);
if
(
ok
)
{
if
(
isCommandBox
)
{
ok
=
CommandZoneAccessor
.
getInstance
(
serverId
).
setFloat64Value
(
containerId
,
id
,
Double
.
valueOf
(
serverValue
));
}
else
{
ok
=
DataAccessor
.
getInstance
(
serverId
).
setFloat64Value
(
containerId
,
id
,
Double
.
valueOf
(
serverValue
));
if
(!
ok
)
{
sendPropertyChangedEvent
();
}
}
showSettingPropertyMessage
(
value
);
}
return
ok
;
}
catch
(
NumberFormatException
nfe
)
{
System
.
err
.
println
(
"Number format exception while setting property "
+
getName
()
+
" to "
+
value
);
ConfigManager
.
CONFIGURATION_ERROR
=
true
;
Double
.
parseDouble
(
value
);
return
true
;
}
catch
(
NumberFormatException
e
)
{
return
false
;
}
}
}
public
String
getType
()
{
return
"float64"
;
}
@Override
protected
String
getPropertyValueFromDatabase
()
{
return
Double
.
valueOf
(
DataAccessor
.
getInstance
(
serverId
).
getFloat64Value
(
containerId
,
id
)).
toString
();
}