Skip to content
Snippets Groups Projects
Commit af2807d2 authored by Pascal Verdier's avatar Pascal Verdier
Browse files

Set device FAULT if an attribute is not managed.

parent 0d9131be
No related branches found
No related tags found
No related merge requests found
# Changelog
#### HdbAttributeCheck -1.3 (04/11/2019):
Set device FAULT if an attribute is not managed.
#### HdbAttributeCheck -1.2 (16/03/2018):
CheckedAttributes attribute added.
......
......@@ -147,11 +147,6 @@ public class HdbAttributeCheck {
subscriberList = new SubscriberList(configuratorManager, attributeList);
setState(DevState.INIT);
/*
try { Thread.sleep(2000); } catch (InterruptedException e) { /* * }
System.out.println("\n");
System.out.println(subscriberList);
*/
/*----- PROTECTED REGION END -----*/ // HdbAttributeCheck.initDevice
xlogger.exit();
......@@ -267,6 +262,7 @@ public class HdbAttributeCheck {
*/
public final DevState getState() throws DevFailed {
/*----- PROTECTED REGION ID(HdbAttributeCheck.getState) ENABLED START -----*/
// ToDo get subscriber state
state = subscriberList.getState();
/*----- PROTECTED REGION END -----*/ // HdbAttributeCheck.getState
return state;
......
......@@ -64,6 +64,7 @@ public class Subscriber extends DeviceProxy {
this.name = deviceName;
// Start a thread to check if manage attributes
new AttributeListThread(checkedAttributeList).start();
// Start a thread to check if device is alive
new PingThread().start();
}
......
......@@ -36,6 +36,7 @@ package org.tango.hdbattributecheck;
import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DevState;
import fr.esrf.TangoApi.DeviceAttribute;
import fr.esrf.TangoApi.DeviceData;
import fr.esrf.TangoApi.DeviceProxy;
import java.util.ArrayList;
......@@ -49,10 +50,30 @@ import java.util.ArrayList;
public class SubscriberList extends ArrayList<Subscriber> {
private DeviceProxy configuratorProxy;
private String attributeStatus = null;
//===============================================================
//===============================================================
public SubscriberList(String configuratorName, String[] checkedAttributes) throws DevFailed {
this.configuratorProxy = new DeviceProxy(configuratorName);
// First time check if attributes are managed
StringBuilder sb = new StringBuilder();
for (String attributeName : checkedAttributes) {
try {
DeviceData argIn = new DeviceData();
argIn.insert(attributeName);
configuratorProxy.command_inout("AttributeStatus", argIn);
}
catch (DevFailed e) {
String desc = e.errors[0].desc;
if (desc.endsWith("not found"))
sb.append(desc).append('\n');
}
}
if (sb.length()>0) {
attributeStatus = sb.toString().trim();
}
String[] archivers = getSubscriberNames();
for (String archiver : archivers) {
add(new Subscriber(archiver, checkedAttributes));
......@@ -67,10 +88,18 @@ public class SubscriberList extends ArrayList<Subscriber> {
//===============================================================
//===============================================================
public String getStatus() {
if (status.isEmpty())
return "Attribute storage is OK";
else
return status;
if (status.isEmpty()) {
if (attributeStatus != null)
return attributeStatus;
else
return "Attribute storage is OK";
}
else {
if (attributeStatus!=null)
return attributeStatus + "\n" + status;
else
return status;
}
}
//===============================================================
private String status = "";
......@@ -82,18 +111,14 @@ public class SubscriberList extends ArrayList<Subscriber> {
int nbAlarm = 0;
// Check state/status on each subscriber
for (Subscriber subscriber : this) {
if (subscriber.getState()==DevState.UNKNOWN) {
if (subscriber.getState() == DevState.UNKNOWN) {
nbUnknown++;
sb.append(subscriber.getStatus()).append('\n');
}
else
if (subscriber.manageAttributes()){
if (subscriber.getState()==DevState.FAULT) {
} else if (subscriber.manageAttributes()) {
if (subscriber.getState() == DevState.FAULT) {
nbFault++;
sb.append(subscriber.getStatus()).append('\n');
}
else
if (subscriber.getState()==DevState.ALARM) {
} else if (subscriber.getState() == DevState.ALARM) {
sb.append(subscriber.getStatus()).append('\n');
nbAlarm++;
}
......@@ -104,11 +129,9 @@ public class SubscriberList extends ArrayList<Subscriber> {
// Check what has higher priority to be returned
if (nbUnknown>0)
return DevState.UNKNOWN;
else
if (nbFault>0)
else if (nbFault>0 || attributeStatus!=null)
return DevState.FAULT;
else
if (nbAlarm>0)
else if (nbAlarm>0)
return DevState.ALARM;
else
return DevState.ON;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment