Skip to content
Snippets Groups Projects
Commit bb8e0c4f authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

- No more use of println: Prefer using slf4j Logger (will help PROBLEM-1604).

- Less silent errors and more use of slf4j Logger (will help PROBLEM-1604).
- Respect java naming convention.
parent edba8160
Branches
No related tags found
No related merge requests found
Showing
with 314 additions and 376 deletions
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.soleil.deviceservers</groupId>
......@@ -24,10 +23,18 @@
</scm>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.tango-controls</groupId>
<artifactId>TangORB</artifactId>
</dependency>
<dependency>
<groupId>org.tango-controls</groupId>
<artifactId>JTangoServer</artifactId>
</dependency>
<dependency>
<groupId>fr.soleil.lib</groupId>
<artifactId>snapArchivingApi</artifactId>
......@@ -36,9 +43,5 @@
<groupId>org.tango-controls</groupId>
<artifactId>JTangoClientLang</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -107,6 +107,8 @@ import java.util.concurrent.Future;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.UserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tango.utils.DevFailedUtils;
import SnapArchiver.grouplink.UsePluginBuilder;
......@@ -143,8 +145,10 @@ import fr.soleil.archiving.snap.api.tools.SnapshotingException;
* Device States Description:
*/
// --------- End of States Description ----------
public class SnapArchiver extends DeviceImpl
/* WithShutdownRunnable */implements TangoConst {
public class SnapArchiver extends DeviceImpl/* WithShutdownRunnable */ implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(SnapArchiver.class);
protected int state;
protected SnapshotPersistenceManager manager;
private final String m_version;
......@@ -176,17 +180,17 @@ public class SnapArchiver extends DeviceImpl
* User identifier (name) used to connect the database for snapshots. <br>
* <b>Default value : </b> archiver
*/
String dbUser;
protected String dbUser;
/**
* Password used to connect the database for snapshots. <br>
* <b>Default value : </b> archiver
*/
String dbPassword;
protected String dbPassword;
/**
* The name of the spring beans file <br>
* <b>Default value : </b> beans.xml
*/
String beansFileName;
protected String beansFileName;
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
private final Map<Integer, Future<Integer>> snapshotResults = new HashMap<Integer, Future<Integer>>();
......@@ -209,16 +213,12 @@ public class SnapArchiver extends DeviceImpl
/**
* Constructor for simulated Time Device Server.
*
* @param cl
* The DeviceClass object
* @param s
* The Device name.
* @param version
* The device version
* @param cl The DeviceClass object
* @param s The Device name.
* @param version The device version
*/
// =========================================================
SnapArchiver(DeviceClass cl, String s, String version) throws DevFailed {
public SnapArchiver(DeviceClass cl, String s, String version) throws DevFailed {
super(cl, s);
m_version = version;
init_device();
......@@ -228,17 +228,13 @@ public class SnapArchiver extends DeviceImpl
/**
* Constructor for simulated Time Device Server.
*
* @param cl
* The DeviceClass object
* @param s
* The Device name.
* @param d
* Device description.
* @param version
* The device version
* @param cl The DeviceClass object
* @param s The Device name.
* @param d Device description.
* @param version The device version
*/
// =========================================================
SnapArchiver(DeviceClass cl, String s, String d, String version) throws DevFailed {
public SnapArchiver(DeviceClass cl, String s, String d, String version) throws DevFailed {
super(cl, s, d);
m_version = version;
init_device();
......@@ -251,7 +247,7 @@ public class SnapArchiver extends DeviceImpl
// =========================================================
@Override
public void init_device() throws DevFailed {
System.out.println("SnapArchiver() create " + device_name);
LOGGER.info("SnapArchiver() create " + device_name);
// Initialise variables to default values
// -------------------------------------------
......@@ -262,7 +258,7 @@ public class SnapArchiver extends DeviceImpl
manager = factory.getManager(beansFileName, dbUser, dbPassword);
set_state(DevState.ON);
} catch (SnapshotingException e) {
get_logger().warn(e.toString(), e);
LOGGER.warn(e.toString(), e);
set_state(DevState.FAULT);
set_status(e.toString());
}
......@@ -295,7 +291,8 @@ public class SnapArchiver extends DeviceImpl
dbPassword = SnapConnectionParameters.getSnapPassword();
isRac = SnapConnectionParameters.getSnapRac();
SnapConnectionParameters.printSnapConnectionInfoLog();
LOGGER.info(SnapConnectionParameters.appendSnapConnectionInfoLog(new StringBuilder("Connection info:\n"))
.toString());
} catch (SnapshotingException e) {
e.printStackTrace();
......@@ -334,7 +331,7 @@ public class SnapArchiver extends DeviceImpl
// =========================================================
@Override
public void always_executed_hook() {
// get_logger().info("In always_executed_hook method()");
// LOGGER.info("In always_executed_hook method()");
}
// =========================================================
......@@ -350,10 +347,10 @@ public class SnapArchiver extends DeviceImpl
// =========================================================
public void trigger_launch_snap_shot(int argin) throws DevFailed {
if (get_state().equals(DevState.RUNNING)) {
DevFailedUtils.throwDevFailed("STATE_ERROR", "snapshot alreadly in progress");
throw DevFailedUtils.newDevFailed("STATE_ERROR", "snapshot alreadly in progress");
}
set_state(DevState.RUNNING);
get_logger().info("Entering trigger_launch_snap_shot()");
LOGGER.info("Entering trigger_launch_snap_shot()");
Future<Integer> snapshotResult = executorService.submit(new SnapshotTask(argin));
snapshotResults.put(argin, snapshotResult);
......@@ -412,8 +409,7 @@ public class SnapArchiver extends DeviceImpl
group.getMessages();
// Map<String, String> messages = group.getMessages();
} catch (SnapshotingException e) {
e.printStackTrace();
Util.out2.println("Exception received during TriggerLaunchSnapshot : " + e.toString());
LOGGER.error("Exception received during TriggerLaunchSnapshot", e);
throw e.toTangoException();
} finally {
SnapArchiver.this.set_state(DevState.ON);
......@@ -437,17 +433,17 @@ public class SnapArchiver extends DeviceImpl
*/
// =========================================================
public void create_new_context(String[] argin) throws DevFailed {
get_logger().info("Entering create_new_context()");
LOGGER.info("Entering create_new_context()");
// ---Add your Own code to control device here ---
SnapContext snapContext = new SnapContext(argin);
try {
SnapManagerApi.createContext(snapContext);
} catch (SnapshotingException e) {
get_logger().warn(e.toString(), e);
LOGGER.warn(e.toString(), e);
throw e.toTangoException();
}
get_logger().info("Exiting create_new_context()");
LOGGER.info("Exiting create_new_context()");
}
// ===================================================================
......@@ -462,7 +458,7 @@ public class SnapArchiver extends DeviceImpl
@Override
public void read_attr(Attribute attr) throws DevFailed {
String attr_name = attr.get_name();
get_logger().info("In read_attr for attribute " + attr_name);
LOGGER.info("In read_attr for attribute " + attr_name);
// Switch on attribute name
// ---------------------------------
......@@ -482,22 +478,18 @@ public class SnapArchiver extends DeviceImpl
Util tg = Util.init(argv, "SnapArchiver");
tg.server_init();
System.out.println("Ready to accept request");
LOGGER.info("Ready to accept request");
tg.server_run();
} catch (OutOfMemoryError ex) {
System.err.println("Can't allocate memory !!!!");
System.err.println("Exiting");
LOGGER.error("Can't allocate memory !!!!");
LOGGER.error("Exiting");
} catch (UserException ex) {
Except.print_exception(ex);
System.err.println("Received a CORBA user exception");
System.err.println("Exiting");
LOGGER.error("Received a CORBA user exception", ex);
LOGGER.error("Exiting");
} catch (SystemException ex) {
Except.print_exception(ex);
System.err.println("Received a CORBA system exception");
System.err.println("Exiting");
LOGGER.error("Received a CORBA system exception", ex);
LOGGER.error("Exiting");
}
System.exit(-1);
......
......@@ -24,6 +24,10 @@
</scm>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.tango-controls</groupId>
<artifactId>JTangoServer</artifactId>
......@@ -31,16 +35,6 @@
<dependency>
<groupId>fr.soleil.lib</groupId>
<artifactId>snapArchivingApi</artifactId>
<exclusions>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.tango-controls</groupId>
......
......@@ -371,7 +371,8 @@ public class SnapExtractor {
dbUser = getProperty(dbUser, SnapConnectionParameters.getSnapUser());
dbPassword = getProperty(dbPassword, SnapConnectionParameters.getSnapPassword());
isRac = getProperty(isRac, SnapConnectionParameters.getSnapRac());
SnapConnectionParameters.printSnapConnectionInfoLog();
logger.info(SnapConnectionParameters.appendSnapConnectionInfoLog(new StringBuilder("Connection info:\n"))
.toString());
}
private String getProperty(final String original, final String newValue) {
......
......@@ -24,10 +24,18 @@
</scm>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.tango-controls</groupId>
<artifactId>TangORB</artifactId>
</dependency>
<dependency>
<groupId>org.tango-controls</groupId>
<artifactId>JTangoServer</artifactId>
</dependency>
<dependency>
<groupId>fr.soleil.lib</groupId>
<artifactId>snapArchivingApi</artifactId>
......@@ -36,9 +44,5 @@
<groupId>org.tango-controls</groupId>
<artifactId>JTangoClientLang</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -46,13 +46,14 @@
package SnapManager;
import org.omg.CORBA.Any;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DispLevel;
import fr.esrf.TangoDs.Command;
import fr.esrf.TangoDs.DeviceImpl;
import fr.esrf.TangoDs.TangoConst;
import fr.esrf.TangoDs.Util;
/**
* Class Description: This command is used to register a snapShot context. All
......@@ -62,16 +63,16 @@ import fr.esrf.TangoDs.Util;
*/
public class CreateNewContextClass extends Command implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(CreateNewContextClass.class);
// ===============================================================
/**
* Constructor for Command class CreateNewContextClass
*
* @param name
* command name
* @param in
* argin type
* @param out
* argout type
* @param name command name
* @param in argin type
* @param out argout type
*/
// ===============================================================
public CreateNewContextClass(String name, int in, int out) {
......@@ -82,16 +83,11 @@ public class CreateNewContextClass extends Command implements TangoConst {
/**
* Constructor for Command class CreateNewContextClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
*/
// ===============================================================
public CreateNewContextClass(String name, int in, int out, String in_comments, String out_comments) {
......@@ -102,21 +98,16 @@ public class CreateNewContextClass extends Command implements TangoConst {
/**
* Constructor for Command class CreateNewContextClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param level
* The command display type OPERATOR or EXPERT
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
* @param level The command display type OPERATOR or EXPERT
*/
// ===============================================================
public CreateNewContextClass(String name, int in, int out, String in_comments, String out_comments, DispLevel level) {
public CreateNewContextClass(String name, int in, int out, String in_comments, String out_comments,
DispLevel level) {
super(name, in, out, in_comments, out_comments, level);
}
......@@ -127,7 +118,7 @@ public class CreateNewContextClass extends Command implements TangoConst {
// ===============================================================
@Override
public Any execute(DeviceImpl device, Any in_any) throws DevFailed {
Util.out2.println("CreateNewContextClass.execute(): arrived");
LOGGER.info("CreateNewContextClass.execute(): arrived");
String[] argin = extract_DevVarStringArray(in_any);
return insert(((SnapManager) (device)).create_new_context(argin));
}
......
......@@ -55,6 +55,8 @@
package SnapManager;
import org.omg.CORBA.Any;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DispLevel;
......@@ -62,7 +64,6 @@ import fr.esrf.TangoDs.Command;
import fr.esrf.TangoDs.DeviceImpl;
import fr.esrf.TangoDs.Except;
import fr.esrf.TangoDs.TangoConst;
import fr.esrf.TangoDs.Util;
/**
* Class Description: This command is used to trigger a snapShot. All
......@@ -71,16 +72,16 @@ import fr.esrf.TangoDs.Util;
*/
public class LaunchSnapShotCmd extends Command implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(LaunchSnapShotCmd.class);
// ===============================================================
/**
* Constructor for Command class LaunchSnapShotCmd
*
* @param name
* command name
* @param in
* argin type
* @param out
* argout type
* @param name command name
* @param in argin type
* @param out argout type
*/
// ===============================================================
public LaunchSnapShotCmd(String name, int in, int out) {
......@@ -91,16 +92,11 @@ public class LaunchSnapShotCmd extends Command implements TangoConst {
/**
* Constructor for Command class LaunchSnapShotCmd
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
*/
// ===============================================================
public LaunchSnapShotCmd(String name, int in, int out, String in_comments, String out_comments) {
......@@ -111,18 +107,12 @@ public class LaunchSnapShotCmd extends Command implements TangoConst {
/**
* Constructor for Command class LaunchSnapShotCmd
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param level
* The command display type OPERATOR or EXPERT
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
* @param level The command display type OPERATOR or EXPERT
*/
// ===============================================================
public LaunchSnapShotCmd(String name, int in, int out, String in_comments, String out_comments, DispLevel level) {
......@@ -136,7 +126,7 @@ public class LaunchSnapShotCmd extends Command implements TangoConst {
// ===============================================================
@Override
public Any execute(DeviceImpl device, Any in_any) throws DevFailed {
Util.out2.println("LaunchSnapShotCmd.execute(): arrived");
LOGGER.info("LaunchSnapShotCmd.execute(): arrived");
int argin = extract_DevLong(in_any);
if (argin < 0) {
Except.throw_exception("INPUT_ERROR", "Invalid Context ID", "SnapManager.LaunchSnapshot");
......
......@@ -32,29 +32,30 @@
package SnapManager;
import org.omg.CORBA.Any;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DispLevel;
import fr.esrf.TangoDs.Command;
import fr.esrf.TangoDs.DeviceImpl;
import fr.esrf.TangoDs.TangoConst;
import fr.esrf.TangoDs.Util;
/**
* Class Description: This command is used to set values to equipments.
*/
public class SetEquipmentsClass extends Command implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(SetEquipmentsClass.class);
// ===============================================================
/**
* Constructor for Command class SetEquipmentsClass
*
* @param name
* command name
* @param in
* argin type
* @param out
* argout type
* @param name command name
* @param in argin type
* @param out argout type
*/
// ===============================================================
public SetEquipmentsClass(String name, int in, int out) {
......@@ -65,16 +66,11 @@ public class SetEquipmentsClass extends Command implements TangoConst {
/**
* Constructor for Command class SetEquipmentsClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
*/
// ===============================================================
public SetEquipmentsClass(String name, int in, int out, String in_comments, String out_comments) {
......@@ -85,18 +81,12 @@ public class SetEquipmentsClass extends Command implements TangoConst {
/**
* Constructor for Command class SetEquipmentsClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param level
* The command display type OPERATOR or EXPERT
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
* @param level The command display type OPERATOR or EXPERT
*/
// ===============================================================
public SetEquipmentsClass(String name, int in, int out, String in_comments, String out_comments, DispLevel level) {
......@@ -110,7 +100,7 @@ public class SetEquipmentsClass extends Command implements TangoConst {
// ===============================================================
@Override
public Any execute(DeviceImpl device, Any in_any) throws DevFailed {
Util.out2.println("SetEquipmentsClass.execute(): arrived");
LOGGER.info("SetEquipmentsClass.execute(): arrived");
String[] argin = extract_DevVarStringArray(in_any);
((SnapManager) (device)).set_equipments(argin);
return insert();
......
......@@ -5,29 +5,30 @@
package SnapManager;
import org.omg.CORBA.Any;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DispLevel;
import fr.esrf.TangoDs.Command;
import fr.esrf.TangoDs.DeviceImpl;
import fr.esrf.TangoDs.TangoConst;
import fr.esrf.TangoDs.Util;
/**
* Class Description: This command is used to set command to equipments.
*/
public class SetEquipmentsWithCommandClass extends Command implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(SetEquipmentsWithCommandClass.class);
// ===============================================================
/**
* Constructor for Command class SetEquipmentsWithCommandClass
*
* @param name
* command name
* @param in
* argin type
* @param out
* argout type
* @param name command name
* @param in argin type
* @param out argout type
*/
// ===============================================================
public SetEquipmentsWithCommandClass(String name, int in, int out) {
......@@ -38,16 +39,11 @@ public class SetEquipmentsWithCommandClass extends Command implements TangoConst
/**
* Constructor for Command class SetEquipmentsWithCommandClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
*/
// ===============================================================
public SetEquipmentsWithCommandClass(String name, int in, int out, String in_comments, String out_comments) {
......@@ -58,18 +54,12 @@ public class SetEquipmentsWithCommandClass extends Command implements TangoConst
/**
* Constructor for Command class SetEquipmentsWithCommandClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param level
* The command display type OPERATOR or EXPERT
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
* @param level The command display type OPERATOR or EXPERT
*/
// ===============================================================
public SetEquipmentsWithCommandClass(String name, int in, int out, String in_comments, String out_comments,
......@@ -84,7 +74,7 @@ public class SetEquipmentsWithCommandClass extends Command implements TangoConst
// ===============================================================
@Override
public Any execute(DeviceImpl device, Any in_any) throws DevFailed {
Util.out2.println("SetEquipmentsWithCommandClass.execute(): arrived");
LOGGER.info("SetEquipmentsWithCommandClass.execute(): arrived");
String[] argin = extract_DevVarStringArray(in_any);
return insert(((SnapManager) (device)).set_equipments_with_command(argin));
......
......@@ -46,30 +46,30 @@
package SnapManager;
import org.omg.CORBA.Any;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DispLevel;
import fr.esrf.TangoDs.Command;
import fr.esrf.TangoDs.DeviceImpl;
import fr.esrf.TangoDs.TangoConst;
import fr.esrf.TangoDs.Util;
/**
* Class Description: This command is used to set values to equipments.
*/
public class SetEquipmentsWithSnapshotClass extends Command implements
TangoConst {
public class SetEquipmentsWithSnapshotClass extends Command implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(SetEquipmentsWithSnapshotClass.class);
// ===============================================================
/**
* Constructor for Command class SetEquipmentsWithSnapshotClass
*
* @param name
* command name
* @param in
* argin type
* @param out
* argout type
* @param name command name
* @param in argin type
* @param out argout type
*/
// ===============================================================
public SetEquipmentsWithSnapshotClass(String name, int in, int out) {
......@@ -80,20 +80,14 @@ public class SetEquipmentsWithSnapshotClass extends Command implements
/**
* Constructor for Command class SetEquipmentsWithSnapshotClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
*/
// ===============================================================
public SetEquipmentsWithSnapshotClass(String name, int in, int out,
String in_comments, String out_comments) {
public SetEquipmentsWithSnapshotClass(String name, int in, int out, String in_comments, String out_comments) {
super(name, in, out, in_comments, out_comments);
}
......@@ -101,22 +95,16 @@ public class SetEquipmentsWithSnapshotClass extends Command implements
/**
* Constructor for Command class SetEquipmentsWithSnapshotClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param level
* The command display type OPERATOR or EXPERT
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
* @param level The command display type OPERATOR or EXPERT
*/
// ===============================================================
public SetEquipmentsWithSnapshotClass(String name, int in, int out,
String in_comments, String out_comments, DispLevel level) {
public SetEquipmentsWithSnapshotClass(String name, int in, int out, String in_comments, String out_comments,
DispLevel level) {
super(name, in, out, in_comments, out_comments, level);
}
......@@ -125,8 +113,9 @@ public class SetEquipmentsWithSnapshotClass extends Command implements
* return the result of the device's command.
*/
// ===============================================================
@Override
public Any execute(DeviceImpl device, Any in_any) throws DevFailed {
Util.out2.println("SetEquipmentsWithSnapshotClass.execute(): arrived");
LOGGER.info("SetEquipmentsWithSnapshotClass.execute(): arrived");
String[] argin = extract_DevVarStringArray(in_any);
((SnapManager) (device)).set_equipments_with_snapshot(argin);
return insert();
......@@ -137,6 +126,7 @@ public class SetEquipmentsWithSnapshotClass extends Command implements
* Check if it is allowed to execute the command.
*/
// ===============================================================
@Override
public boolean is_allowed(DeviceImpl device, Any data_in) {
// End of Generated Code
......
......@@ -124,6 +124,8 @@ import java.util.concurrent.Future;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.UserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tango.utils.DevFailedUtils;
import fr.esrf.Tango.DevError;
......@@ -161,8 +163,10 @@ import fr.soleil.tango.clientapi.TangoCommand;
* Device States Description:
*/
// --------- End of States Description ----------
public class SnapManager extends DeviceImpl
/* WithShutdownRunnable */implements TangoConst {
public class SnapManager extends DeviceImpl/* WithShutdownRunnable */ implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(SnapManager.class);
protected int state;
private final String m_version;
// --------- Start of attributes data members ----------
......@@ -174,12 +178,12 @@ public class SnapManager extends DeviceImpl
* User identifier (name) used to connect the database for snapshots. <br>
* <b>Default value : </b> archiver
*/
String dbUser;
protected String dbUser;
/**
* Password used to connect the database for snapshots. <br>
* <b>Default value : </b> archiver
*/
String dbPassword;
protected String dbPassword;
// --------- End of properties data members ----------
......@@ -208,7 +212,7 @@ public class SnapManager extends DeviceImpl
* The device version
*/
// =========================================================
SnapManager(DeviceClass cl, String s, String version) throws DevFailed {
public SnapManager(DeviceClass cl, String s, String version) throws DevFailed {
super(cl, s);
m_version = version;
init_device();
......@@ -228,7 +232,7 @@ public class SnapManager extends DeviceImpl
* The device version
*/
// =========================================================
SnapManager(DeviceClass cl, String s, String d, String version) throws DevFailed {
public SnapManager(DeviceClass cl, String s, String d, String version) throws DevFailed {
super(cl, s, d);
m_version = version;
init_device();
......@@ -241,7 +245,7 @@ public class SnapManager extends DeviceImpl
// =========================================================
@Override
public void init_device() throws DevFailed {
System.out.println("SnapManager() create " + device_name);
LOGGER.info("SnapManager() create " + device_name);
// Initialise variables to default values
// -------------------------------------------
......@@ -252,7 +256,7 @@ public class SnapManager extends DeviceImpl
SnapManagerApi.initSnapConnection(dbHost, dbName, dbSchema, dbUser, dbPassword, isRac);
set_state(DevState.ON);
} catch (SnapshotingException e) {
get_logger().warn(e.toString(), e);
LOGGER.warn(e.toString(), e);
set_state(DevState.FAULT);
set_status(e.toString());
// throw e.toTangoException();
......@@ -286,7 +290,8 @@ public class SnapManager extends DeviceImpl
dbPassword = SnapConnectionParameters.getSnapPassword();
isRac = SnapConnectionParameters.getSnapRac();
SnapConnectionParameters.printSnapConnectionInfoLog();
LOGGER.info(SnapConnectionParameters.appendSnapConnectionInfoLog(new StringBuilder("Connection info:\n"))
.toString());
} catch (SnapshotingException e) {
e.printStackTrace();
......@@ -300,7 +305,7 @@ public class SnapManager extends DeviceImpl
// =========================================================
@Override
public void always_executed_hook() {
// get_logger().info("In always_executed_hook method()");
// LOGGER.info("In always_executed_hook method()");
}
// =========================================================
......@@ -321,17 +326,17 @@ public class SnapManager extends DeviceImpl
// =========================================================
public int create_new_context(String[] argin) throws DevFailed {
int argout = -1;
get_logger().info("Entering create_new_context()");
LOGGER.info("Entering create_new_context()");
// ---Add your Own code to control device here ---
SnapContext snapContext = new SnapContext(argin);
try {
argout = SnapManagerApi.createContext(snapContext);
} catch (SnapshotingException e) {
get_logger().warn(e.toString(), e);
LOGGER.warn(e.toString(), e);
throw e.toTangoException();
}
get_logger().info("Exiting create_new_context()");
LOGGER.info("Exiting create_new_context()");
return argout;
}
......@@ -347,7 +352,7 @@ public class SnapManager extends DeviceImpl
*/
// =========================================================
public void launch_snap_shot(int argin) throws DevFailed {
get_logger().info("Entering launch_snap_shot()");
LOGGER.info("Entering launch_snap_shot()");
if (get_state().equals(DevState.RUNNING)) {
DevFailedUtils.throwDevFailed("STATE_ERROR", "snapshot alreadly in progress");
}
......@@ -390,12 +395,12 @@ public class SnapManager extends DeviceImpl
try {
snapShot = m_manager.launchSnapshot(context);
} catch (SnapshotingException e) {
get_logger().warn(e.toString(), e);
LOGGER.warn(e.toString(), e);
throw e.toTangoException();
} finally {
SnapManager.this.set_state(DevState.ON);
}
get_logger().info("Exiting launch_snap_shot()");
LOGGER.info("Exiting launch_snap_shot()");
return snapShot.getId_snap();
}
......@@ -411,7 +416,7 @@ public class SnapManager extends DeviceImpl
*/
// =========================================================
public void set_equipments_with_snapshot(String[] argin) throws DevFailed {
get_logger().info("Entering set_equipments_with_snapshot() xxx");
LOGGER.info("Entering set_equipments_with_snapshot() xxx");
try {
// System.out.println("set_equipments_with_snapshot(String[] argin)");
Snapshot snapShot = new Snapshot(argin);
......@@ -420,7 +425,7 @@ public class SnapManager extends DeviceImpl
SnapManagerApi.TriggerSetEquipments(snapShot);
} catch (SnapshotingException e) {
e.printStackTrace();
get_logger().warn(e.toString(), e);
LOGGER.warn(e.toString(), e);
throw e.toTangoException();
} catch (Exception e) {
e.printStackTrace();
......@@ -428,7 +433,7 @@ public class SnapManager extends DeviceImpl
} catch (Throwable t) {
t.printStackTrace();
}
get_logger().info("Exiting set_equipments_with_snapshot()");
LOGGER.info("Exiting set_equipments_with_snapshot()");
}
// =========================================================
......@@ -506,7 +511,7 @@ public class SnapManager extends DeviceImpl
value = attributeSnap.getReadValue();
}
}
System.out.println(command_name + " with " + value + " on " + attributeSnap.getdeviceName());
LOGGER.info(command_name + " with " + value + " on " + attributeSnap.getdeviceName());
cmd.execute(value);
if (!cmd.isArginVoid()) {
result.add(cmd.extractToString(","));
......@@ -527,7 +532,8 @@ public class SnapManager extends DeviceImpl
} catch (SnapshotingException e) {
Except.throw_exception("CONFIGURATION_ERROR", e.getMessage(), "SnapManager.SetEquipmentsWithCommand");
} catch (NumberFormatException e1) {
Except.throw_exception("CONFIGURATION_ERROR", "Invalid snapshot ID", "SnapManager.SetEquipmentsWithCommand");
Except.throw_exception("CONFIGURATION_ERROR", "Invalid snapshot ID",
"SnapManager.SetEquipmentsWithCommand");
}
return "";
......@@ -547,7 +553,8 @@ public class SnapManager extends DeviceImpl
}
for (int i = 1; i < selectedAttributes.length; i++) {
if (selectedAttributes[i].getDataFormat() != format) {
Except.throw_exception("CONFIGURATION_ERROR", "Some attributes have incompatible format : "
Except.throw_exception(
"CONFIGURATION_ERROR", "Some attributes have incompatible format : "
+ selectedAttributes[i].getDataFormat() + " and " + format,
"SnapManager.SetEquipmentsWithCommand");
return false;
......@@ -604,7 +611,7 @@ public class SnapManager extends DeviceImpl
*/
// =========================================================
public void set_equipments(String[] argin) throws DevFailed {
get_logger().info("Entering set_equipments() xxx");
LOGGER.info("Entering set_equipments() xxx");
// System.out.println("set_equipments(String[] argin)");
// ---Add your Own code to control device here ---
// System.out.println("snapshot : " + snapShot.toString());
......@@ -631,7 +638,7 @@ public class SnapManager extends DeviceImpl
}
SnapManagerApi.TriggerSetEquipments(snapShot);
} catch (SnapshotingException e) {
get_logger().warn(e.toString(), e);
LOGGER.warn(e.toString(), e);
throw e.toTangoException();
} catch (NumberFormatException e) {
Except.throw_exception("CONFIGURATION_ERROR", "Wrong parameters values ", "SnapManager.SetEquipments");
......@@ -641,7 +648,7 @@ public class SnapManager extends DeviceImpl
t.printStackTrace();
}
}
get_logger().info("Exiting set_equipments()");
LOGGER.info("Exiting set_equipments()");
}
// =========================================================
......@@ -655,7 +662,7 @@ public class SnapManager extends DeviceImpl
*/
// =========================================================
public void update_snap_comment(DevVarLongStringArray argin) throws DevFailed {
get_logger().info("Entering update_snap_comment()");
LOGGER.info("Entering update_snap_comment()");
// ---Add your Own code to control device here ---
int id_snap = argin.lvalue[0];
......@@ -663,10 +670,10 @@ public class SnapManager extends DeviceImpl
try {
SnapManagerApi.updateSnapComment(id_snap, comment);
} catch (SnapshotingException e) {
get_logger().warn(e.toString(), e);
LOGGER.warn(e.toString(), e);
throw e.toTangoException();
}
get_logger().info("Exiting update_snap_comment()");
LOGGER.info("Exiting update_snap_comment()");
}
public String getSnapComment(int snapID) throws DevFailed {
......@@ -689,7 +696,7 @@ public class SnapManager extends DeviceImpl
@Override
public void read_attr(Attribute attr) throws DevFailed {
String attr_name = attr.get_name();
get_logger().info("In read_attr for attribute " + attr_name);
LOGGER.info("In read_attr for attribute " + attr_name);
// Switch on attribute name
// ---------------------------------
......@@ -709,24 +716,20 @@ public class SnapManager extends DeviceImpl
Util tg = Util.init(argv, "SnapManager");
tg.server_init();
System.out.println("Ready to accept request");
LOGGER.info("Ready to accept request");
tg.server_run();
}
catch (OutOfMemoryError ex) {
System.err.println("Can't allocate memory !!!!");
System.err.println("Exiting");
LOGGER.error("Can't allocate memory !!!!", ex);
LOGGER.error("Exiting");
} catch (UserException ex) {
Except.print_exception(ex);
System.err.println("Received a CORBA user exception");
System.err.println("Exiting");
LOGGER.error("Received a CORBA user exception", ex);
LOGGER.error("Exiting");
} catch (SystemException ex) {
Except.print_exception(ex);
System.err.println("Received a CORBA system exception");
System.err.println("Exiting");
LOGGER.error("Received a CORBA system exception", ex);
LOGGER.error("Exiting");
}
System.exit(-1);
......
......@@ -70,6 +70,9 @@ import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Vector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.AttrWriteType;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DispLevel;
......@@ -83,6 +86,9 @@ import fr.esrf.TangoDs.TemplCommandInOut;
import fr.esrf.TangoDs.Util;
public class SnapManagerClass extends DeviceClass implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(SnapManagerClass.class);
// --------- Start of properties data members ----------
/**
......@@ -90,17 +96,17 @@ public class SnapManagerClass extends DeviceClass implements TangoConst {
* can be the computer name or its IP address. <br>
* <b>Default value : </b> localhost.
*/
String dbHost;
private String dbHost;
/**
* Database name.<br>
* <b>Default value : </b> hdb
*/
String dbName;
private String dbName;
/**
* Database schema name.<br>
* <b>Default value : </b> snap
*/
String dbSchema;
private String dbSchema;
// --------- End of properties data members ----------
......@@ -128,8 +134,8 @@ public class SnapManagerClass extends DeviceClass implements TangoConst {
// ===================================================================
public static SnapManagerClass instance() {
if (_instance == null) {
System.err.println("SnapManagerClass is not initialised !!!");
System.err.println("Exiting");
LOGGER.error("SnapManagerClass is not initialised !!!");
LOGGER.error("Exiting");
System.exit(-1);
}
return _instance;
......@@ -165,11 +171,11 @@ public class SnapManagerClass extends DeviceClass implements TangoConst {
protected SnapManagerClass(final String name) throws DevFailed {
super(name);
Util.out2.println("Entering SnapManagerClass constructor");
LOGGER.info("Entering SnapManagerClass constructor");
// write_class_property();
get_class_property();
Util.out2.println("Leaving SnapManagerClass constructor");
LOGGER.info("Leaving SnapManagerClass constructor");
}
// ===================================================================
......@@ -184,23 +190,16 @@ public class SnapManagerClass extends DeviceClass implements TangoConst {
command_list.addElement(new CreateNewContextClass("CreateNewContext", Tango_DEVVAR_STRINGARRAY, Tango_DEV_LONG,
"All the informations usefull to create a context ,Snapshot pattern).", "The new assigned context ID",
DispLevel.OPERATOR));
command_list.addElement(new SetEquipmentsWithSnapshotClass("SetEquipmentsWithSnapshot",
Tango_DEVVAR_STRINGARRAY, Tango_DEV_VOID, "The snapshot from which equipments are set.", "",
DispLevel.OPERATOR));
command_list
.addElement(new SetEquipmentsWithCommandClass(
"SetEquipmentsWithCommand",
Tango_DEVVAR_STRINGARRAY,
.addElement(new SetEquipmentsWithSnapshotClass("SetEquipmentsWithSnapshot", Tango_DEVVAR_STRINGARRAY,
Tango_DEV_VOID, "The snapshot from which equipments are set.", "", DispLevel.OPERATOR));
command_list.addElement(new SetEquipmentsWithCommandClass("SetEquipmentsWithCommand", Tango_DEVVAR_STRINGARRAY,
Tango_DEV_STRING,
"The command name, STORED_READ_VALUE || STORED_WRITE_VALUE ,\n and the snapshot ID from which equipments are set.",
"", DispLevel.OPERATOR));
command_list
.addElement(new SetEquipmentsClass(
"SetEquipments",
Tango_DEVVAR_STRINGARRAY,
Tango_DEV_VOID,
command_list.addElement(new SetEquipmentsClass("SetEquipments", Tango_DEVVAR_STRINGARRAY, Tango_DEV_VOID,
"* First Case: Setpoint is done on all the snapshot attributes:\n"
+ " - argin[0]= the snap identifier\n"
+ " - argin[1]=STORED_READ_VALUE (Setpoint with theirs read values) or STORED_WRITE_VALUE (Setpoint with theirs write values)\n\n"
......@@ -209,8 +208,8 @@ public class SnapManagerClass extends DeviceClass implements TangoConst {
+ " Let us note index the last index used (for example, at this point,index = 2).\n"
+ " - argin[index]=NEW_VALUE or STORED_READ_VALUE or STORED_WRITE_VALUE\n"
+ " - argin[index+1]= the attribut name\n"
+ " - argin[index+2]= the value to set when NEW_VALUE is requested", "",
DispLevel.OPERATOR));
+ " - argin[index+2]= the value to set when NEW_VALUE is requested",
"", DispLevel.OPERATOR));
command_list.addElement(new UpdateSnapCommentClass("UpdateSnapComment", Tango_DEVVAR_LONGSTRINGARRAY,
Tango_DEV_VOID, "1) snapshot identifier 2) The new comment", "", DispLevel.OPERATOR));
......
......@@ -34,6 +34,8 @@
package SnapManager;
import org.omg.CORBA.Any;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DevVarLongStringArray;
......@@ -41,23 +43,22 @@ import fr.esrf.Tango.DispLevel;
import fr.esrf.TangoDs.Command;
import fr.esrf.TangoDs.DeviceImpl;
import fr.esrf.TangoDs.TangoConst;
import fr.esrf.TangoDs.Util;
/**
* Class Description: This command updates the comment of given snapshot
*
*/
public class UpdateSnapCommentClass extends Command implements TangoConst {
private static final Logger LOGGER = LoggerFactory.getLogger(UpdateSnapCommentClass.class);
// ===============================================================
/**
* Constructor for Command class UpdateSnapCommentClass
*
* @param name
* command name
* @param in
* argin type
* @param out
* argout type
* @param name command name
* @param in argin type
* @param out argout type
*/
// ===============================================================
public UpdateSnapCommentClass(String name, int in, int out) {
......@@ -68,16 +69,11 @@ public class UpdateSnapCommentClass extends Command implements TangoConst {
/**
* Constructor for Command class UpdateSnapCommentClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
*/
// ===============================================================
public UpdateSnapCommentClass(String name, int in, int out, String in_comments, String out_comments) {
......@@ -88,21 +84,16 @@ public class UpdateSnapCommentClass extends Command implements TangoConst {
/**
* Constructor for Command class UpdateSnapCommentClass
*
* @param name
* command name
* @param in
* argin type
* @param in_comments
* argin description
* @param out
* argout type
* @param out_comments
* argout description
* @param level
* The command display type OPERATOR or EXPERT
* @param name command name
* @param in argin type
* @param in_comments argin description
* @param out argout type
* @param out_comments argout description
* @param level The command display type OPERATOR or EXPERT
*/
// ===============================================================
public UpdateSnapCommentClass(String name, int in, int out, String in_comments, String out_comments, DispLevel level) {
public UpdateSnapCommentClass(String name, int in, int out, String in_comments, String out_comments,
DispLevel level) {
super(name, in, out, in_comments, out_comments, level);
}
......@@ -113,7 +104,7 @@ public class UpdateSnapCommentClass extends Command implements TangoConst {
// ===============================================================
@Override
public Any execute(DeviceImpl device, Any in_any) throws DevFailed {
Util.out2.println("UpdateSnapCommentClass.execute(): arrived");
LOGGER.info("UpdateSnapCommentClass.execute(): arrived");
DevVarLongStringArray argin = extract_DevVarLongStringArray(in_any);
((SnapManager) (device)).update_snap_comment(argin);
return insert();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment