
org.tango.server.testserver.TestDevice Maven / Gradle / Ivy
The newest version!
package org.tango.server.testserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tango.server.ServerManager;
import org.tango.server.annotation.Attribute;
import org.tango.server.annotation.AttributeProperties;
import org.tango.server.annotation.Command;
import org.tango.server.annotation.Delete;
import org.tango.server.annotation.Device;
import org.tango.server.annotation.Init;
@Device
public class TestDevice {
private final Logger logger = LoggerFactory.getLogger(TestDevice.class);
public static final String SERVER_NAME = TestDevice.class.getSimpleName();
public static final String INSTANCE_NAME = "1";
/**
* Attribute testAttribute READ WRITE, type DevDouble.
* Default polling period configured like also archive event
*/
@Attribute(isPolled=true, pollingPeriod = 3000)
@AttributeProperties(archiveEventAbsolute = "10")
public double testAttribute;
/**
* Starts the server.
*/
public static void main(final String[] args) {
ServerManager.getInstance().addClass(TestDevice.class.getCanonicalName(), TestDevice.class);
ServerManager.getInstance().start(new String[]{INSTANCE_NAME}, SERVER_NAME);
}
/**
* init device
*/
@Init
public void init() {
logger.debug("Init device");
}
/**
* delete device
*/
@Delete
public void delete() {
logger.debug("delete command executed");
}
/**
* Execute command start. Type VOID-VOID
*/
@Command
public void start() {
logger.debug("start command executed");
}
/**
* Read attribute myAttribute.
*
* @return
*/
public double getTestAttribute() {
logger.debug("Get Test Attribute {}", testAttribute);
return testAttribute;
}
/**
* Write new attribute value for TestAttribute
*
* @param testAttribute
*/
public void setTestAttribute(final double testAttribute) {
logger.debug("setMyAttribute {}", testAttribute);
this.testAttribute = testAttribute;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy