/*----- PROTECTED REGION ID(UserEventTest.java) ENABLED START -----*/
//=============================================================================
//
// file : UserEventTest.java
//
// description : Java source for the UserEventTest class and its commands.
// The class is derived from Device. It represents the
// CORBA servant object which will be accessed from the
// network. All commands which can be executed on the
// UserEventTest are implemented in this file.
//
// project :
//
// This file is part of Tango device class.
//
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Tango. If not, see .
//
// $Author: $
//
// $Revision: $
// $Date: $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
/*----- PROTECTED REGION END -----*/ // UserEventTest.java
package org.tango.usereventtest;
/*----- PROTECTED REGION ID(UserEventTest.imports) ENABLED START -----*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
import org.tango.DeviceState;
import org.tango.server.InvocationContext;
import org.tango.server.ServerManager;
import org.tango.server.annotation.AroundInvoke;
import org.tango.server.annotation.Attribute;
import org.tango.server.annotation.AttributeProperties;
import org.tango.server.annotation.ClassProperty;
import org.tango.server.annotation.Command;
import org.tango.server.annotation.Delete;
import org.tango.server.annotation.Device;
import org.tango.server.annotation.DeviceManagement;
import org.tango.server.annotation.DeviceProperty;
import org.tango.server.annotation.DynamicManagement;
import org.tango.server.annotation.Init;
import org.tango.server.annotation.State;
import org.tango.server.annotation.StateMachine;
import org.tango.server.annotation.Status;
import org.tango.server.device.DeviceManager;
import org.tango.server.dynamic.DynamicManager;
import org.tango.server.events.EventType;
import org.tango.utils.DevFailedUtils;
// Import Tango IDL types
import fr.esrf.Tango.*;
import fr.esrf.TangoApi.events.TangoChange;
import org.tango.server.attribute.AttributeValue;
/*----- PROTECTED REGION END -----*/ // UserEventTest.imports
/**
* UserEventTest class description:
*
*/
@Device
public class UserEventTest {
private static final Logger logger = LoggerFactory.getLogger(UserEventTest.class);
private static final XLogger xlogger = XLoggerFactory.getXLogger(UserEventTest.class);
//========================================================
// Programmer's data members
//========================================================
/*----- PROTECTED REGION ID(UserEventTest.variables) ENABLED START -----*/
// Put static variables here
/*----- PROTECTED REGION END -----*/ // UserEventTest.variables
/*----- PROTECTED REGION ID(UserEventTest.private) ENABLED START -----*/
// Put private variables here
@DeviceManagement
DeviceManager deviceManager;
/*----- PROTECTED REGION END -----*/ // UserEventTest.private
//========================================================
// Property data members and related methods
//========================================================
//========================================================
// Miscellaneous methods
//========================================================
/**
* Initialize the device.
*
* @throws DevFailed if something fails during the device initialization.
*/
@Init(lazyLoading = false)
public final void initDevice() throws DevFailed {
xlogger.entry();
logger.debug("init");
/*----- PROTECTED REGION ID(UserEventTest.initDevice) ENABLED START -----*/
// Put your device initialization code here
this.number=0;
/*----- PROTECTED REGION END -----*/ // UserEventTest.initDevice
xlogger.exit();
}
/**
* all resources may be closed here. Collections may be also cleared.
*
* @throws DevFailed if something fails during the device object delation.
*/
@Delete
public final void deleteDevice() throws DevFailed {
xlogger.entry();
/*----- PROTECTED REGION ID(UserEventTest.deleteDevice) ENABLED START -----*/
// Put your device clearing code here
/*----- PROTECTED REGION END -----*/ // UserEventTest.deleteDevice
xlogger.exit();
}
/**
* Method called before and after command and attribute calls.
* @param ctx the invocation context
* @throws DevFailed if something fails during the this method execution.
*/
@AroundInvoke
public final void aroundInvoke(final InvocationContext ctx) throws DevFailed {
xlogger.entry(ctx);
/*----- PROTECTED REGION ID(UserEventTest.aroundInvoke) ENABLED START -----*/
// Put aroundInvoke code here
/*----- PROTECTED REGION END -----*/ // UserEventTest.aroundInvoke
xlogger.exit();
}
/**
* dynamic command and attribute management. Will be injected by the framework.
*/
@DynamicManagement
private DynamicManager dynamicManager;
/**
* @param dynamicManager the DynamicManager instance
*/
public void setDynamicManager(final DynamicManager dynamicManager) {
this.dynamicManager = dynamicManager;
/*----- PROTECTED REGION ID(UserEventTest.setDynamicManager) ENABLED START -----*/
// Put your code here
/*----- PROTECTED REGION END -----*/ // UserEventTest.setDynamicManager
}
//========================================================
// Attribute data members and related methods
//========================================================
/**
* Attribute Number, double, Scalar, READ_WRITE
* description:
*
*/
@Attribute(name="Number")
private double number;
/**
* Read attribute Number
*
* @return attribute value
*/
public double getNumber() {
xlogger.entry();
/*----- PROTECTED REGION ID(UserEventTest.getNumber) ENABLED START -----*/
// Put read attribute code here
/*----- PROTECTED REGION END -----*/ // UserEventTest.getNumber
xlogger.exit();
return number;
}
/**
* Write attribute Number
* @param number value to write
* @throws DevFailed
*/
public void setNumber(double number) throws DevFailed{
xlogger.entry();
/*----- PROTECTED REGION ID(UserEventTest.setNumber) ENABLED START -----*/
// Put write attribute code here
this.number = number;
if(number == 13){
this.number = number;
deviceManager.pushEvent("number", new AttributeValue(getNumber()), EventType.USER_EVENT);
}
/*----- PROTECTED REGION END -----*/ // UserEventTest.setNumber
xlogger.exit();
}
//========================================================
// Command data members and related methods
//========================================================
/**
* The state of the device
*/
@State
private DevState state = DevState.UNKNOWN;
/**
* Execute command "State".
* description: This command gets the device state (stored in its 'state' data member) and returns it to the caller.
* @return Device state
* @throws DevFailed if command execution failed.
*/
public final DevState getState() throws DevFailed {
/*----- PROTECTED REGION ID(UserEventTest.getState) ENABLED START -----*/
// Put state code here
/*----- PROTECTED REGION END -----*/ // UserEventTest.getState
return state;
}
/**
* Set the device state
* @param state the new device state
*/
public void setState(final DevState state) {
this.state = state;
}
/**
* The status of the device
*/
@Status
private String status = "Server is starting. The device state is unknown";
/**
* Execute command "Status".
* description: This command gets the device status (stored in its 'status' data member) and returns it to the caller.
* @return Device status
* @throws DevFailed if command execution failed.
*/
public final String getStatus() throws DevFailed {
/*----- PROTECTED REGION ID(UserEventTest.getStatus) ENABLED START -----*/
// Put status code here
/*----- PROTECTED REGION END -----*/ // UserEventTest.getStatus
return status;
}
/**
* Set the device status
* @param status the new device status
*/
public void setStatus(final String status) {
this.status = status;
}
//========================================================
// Programmer's methods
//========================================================
/*----- PROTECTED REGION ID(UserEventTest.methods) ENABLED START -----*/
// Put your own methods here
public void setDeviceManager(final DeviceManager deviceManager) {
this.deviceManager = deviceManager;
}
/*----- PROTECTED REGION END -----*/ // UserEventTest.methods
/**
* Starts the server.
* @param args program arguments (instance_name [-v[trace level]] [-nodb [-dlist ] [-file=fileName]])
*/
public static void main(final String[] args) {
ServerManager.getInstance().start(args, UserEventTest.class);
System.out.println("------- Started -------------");
}
}