use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class DataCollectionTest method testGetThresholdSummary.
public void testGetThresholdSummary() throws Exception {
final NXCSession session = connect();
session.syncObjects();
final List<ThresholdViolationSummary> list = session.getThresholdSummary(1);
for (ThresholdViolationSummary s : list) {
DataCollectionTarget target = (DataCollectionTarget) session.findObjectById(s.getNodeId(), DataCollectionTarget.class);
System.out.println("* " + target.getObjectName());
if (s.getDciList().size() > 0) {
for (DciValue v : s.getDciList()) {
System.out.println(" + " + v.getDescription());
}
} else {
System.out.println(" --- no threshold violations");
}
}
session.disconnect();
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class NXCSession method sendLastValuesMsg.
/**
* Send msg containing list of dci configurations
*
* @param msg The NXCPMessage to send
* @return The DCI values
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public DciValue[] sendLastValuesMsg(NXCPMessage msg) throws IOException, NXCException {
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ITEMS);
DciValue[] list = new DciValue[count];
long base = NXCPCodes.VID_DCI_VALUES_BASE;
for (int i = 0; i < count; i++, base += 10) {
list[i] = (DciValue) new SimpleDciValue(response, base);
}
return list;
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class LastValuesFragment method showTableLastValue.
/**
* Show last value for table DCI
*
* @param idList list of DCI to graph
* @return
*/
private boolean showTableLastValue(ArrayList<Long> idList) {
if (idList.size() > 0) {
DciValue value = (DciValue) adapter.getItem(idList.get(0).intValue());
Intent newIntent = new Intent(getActivity(), TableLastValues.class);
newIntent.putExtra("nodeId", (int) nodeId);
newIntent.putExtra("dciId", (int) value.getId());
newIntent.putExtra("description", value.getDescription());
startActivity(newIntent);
}
return true;
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class LastValuesFragment method drawGraph.
/**
* Draw graph for the specified time slot
*
* @param secsBack seconds back since current time
* @param idList list of DCI to graph
* @return Always true
*/
private boolean drawGraph(long secsBack, ArrayList<Long> idList) {
if (idList.size() > 0) {
ArrayList<Integer> nodeIdList = new ArrayList<Integer>();
ArrayList<Integer> dciIdList = new ArrayList<Integer>();
ArrayList<Integer> colorList = new ArrayList<Integer>();
ArrayList<Integer> lineWidthList = new ArrayList<Integer>();
ArrayList<String> nameList = new ArrayList<String>();
// Set values
int count = 0;
for (int i = 0; i < idList.size() && count < MAX_COLORS; i++) {
DciValue value = (DciValue) adapter.getItem(idList.get(i).intValue());
if (value != null && value.getDcObjectType() == DataCollectionObject.DCO_TYPE_ITEM) {
nodeIdList.add((int) nodeId);
dciIdList.add((int) value.getId());
colorList.add(DEFAULT_COLORS[count]);
lineWidthList.add(3);
nameList.add(value.getDescription());
count++;
}
}
// Pass them to activity
if (count > 0) {
Intent newIntent = new Intent(getActivity(), DrawGraph.class);
if (count == 1)
newIntent.putExtra("graphTitle", nameList.get(0));
newIntent.putExtra("numGraphs", count);
newIntent.putIntegerArrayListExtra("nodeIdList", nodeIdList);
newIntent.putIntegerArrayListExtra("dciIdList", dciIdList);
newIntent.putIntegerArrayListExtra("colorList", colorList);
newIntent.putIntegerArrayListExtra("lineWidthList", lineWidthList);
newIntent.putStringArrayListExtra("nameList", nameList);
newIntent.putExtra("timeFrom", System.currentTimeMillis() - secsBack * 1000);
newIntent.putExtra("timeTo", System.currentTimeMillis());
startActivity(newIntent);
}
}
return true;
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class LastValuesFragment method onCreateContextMenu.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
android.view.MenuInflater inflater = getActivity().getMenuInflater();
DciValue value = (DciValue) adapter.getItem(((AdapterView.AdapterContextMenuInfo) menuInfo).position);
if (value != null) {
switch(value.getDcObjectType()) {
case DataCollectionObject.DCO_TYPE_ITEM:
inflater.inflate(R.menu.last_values_actions, menu);
break;
case DataCollectionObject.DCO_TYPE_TABLE:
inflater.inflate(R.menu.last_values_table_actions, menu);
break;
}
}
}
Aggregations