use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method getAddressList.
/**
* Get address list.
*
* @param listId list identifier (defined in NXCSession as ADDRESS_LIST_xxx)
* @return address list
* @throws IOException if socket or file I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<InetAddressListElement> getAddressList(int listId) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_ADDR_LIST);
msg.setFieldInt32(NXCPCodes.VID_ADDR_LIST_TYPE, listId);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_RECORDS);
final List<InetAddressListElement> list = new ArrayList<InetAddressListElement>(count);
long varId = NXCPCodes.VID_ADDR_LIST_BASE;
for (int i = 0; i < count; i++) {
list.add(new InetAddressListElement(response, varId));
varId += 10;
}
return list;
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method pushDciData.
/**
* Push data to server.
*
* @param data push data
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void pushDciData(DciPushData[] data) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_PUSH_DCI_DATA);
msg.setFieldInt32(NXCPCodes.VID_NUM_ITEMS, data.length);
long varId = NXCPCodes.VID_PUSH_DCI_DATA_BASE;
for (DciPushData d : data) {
msg.setFieldInt32(varId++, (int) d.nodeId);
if (d.nodeId == 0)
msg.setField(varId++, d.nodeName);
msg.setFieldInt32(varId++, (int) d.dciId);
if (d.dciId == 0)
msg.setField(varId++, d.dciName);
msg.setField(varId++, d.value);
}
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method testTransformationScript.
/**
* Test DCI transformation script.
*
* @param nodeId ID of the node object to test script on
* @param script script source code
* @param inputValue input value for the script
* @return test execution results
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public TransformationTestResult testTransformationScript(long nodeId, String script, String inputValue) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_TEST_DCI_TRANSFORMATION);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
msg.setField(NXCPCodes.VID_SCRIPT, script);
msg.setField(NXCPCodes.VID_VALUE, inputValue);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
TransformationTestResult r = new TransformationTestResult();
r.success = response.getFieldAsBoolean(NXCPCodes.VID_EXECUTION_STATUS);
r.result = response.getFieldAsString(NXCPCodes.VID_EXECUTION_RESULT);
return r;
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method resetServerComponent.
/**
* Reset server's internal component (defined by SERVER_COMPONENT_xxx)
*
* @param component component id
* @throws IOException if socket or file I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void resetServerComponent(int component) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_RESET_COMPONENT);
msg.setFieldInt32(NXCPCodes.VID_COMPONENT_ID, component);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method listReportResults.
/**
* List report results
*
* @param reportId The report UUID
* @return List of ReportResult objects
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<ReportResult> listReportResults(UUID reportId) throws NXCException, IOException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_RS_LIST_RESULTS);
msg.setField(NXCPCodes.VID_REPORT_DEFINITION, reportId);
sendMessage(msg);
NXCPMessage response = waitForRCC(msg.getMessageId());
List<ReportResult> results = new ArrayList<ReportResult>();
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ITEMS);
long base = NXCPCodes.VID_ROW_DATA_BASE;
for (int i = 0; i < count; i++, base += 10) {
ReportResult result = ReportResult.createFromMessage(response, base);
results.add(result);
}
return results;
}
Aggregations