use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method getLastValues.
/**
* Get last DCI values for given node
*
* @param nodeId ID of the node to get DCI values for
* @param objectTooltipOnly if set to true, only DCIs with DCF_SHOW_ON_OBJECT_TOOLTIP flag set are returned
* @param overviewOnly if set to true, only DCIs with DCF_SHOW_IN_OBJECT_OVERVIEW flag set are returned
* @param includeNoValueObjects if set to true, objects with no value (like instance discovery DCIs) will be returned as well
* @return List of 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[] getLastValues(final long nodeId, boolean objectTooltipOnly, boolean overviewOnly, boolean includeNoValueObjects) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_LAST_VALUES);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
msg.setField(NXCPCodes.VID_OBJECT_TOOLTIP_ONLY, objectTooltipOnly);
msg.setField(NXCPCodes.VID_OVERVIEW_ONLY, overviewOnly);
msg.setField(NXCPCodes.VID_INCLUDE_NOVALUE_OBJECTS, includeNoValueObjects);
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 += 50) {
list[i] = DciValue.createFromMessage(nodeId, response, base);
}
return list;
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method syncObjects.
/**
* Synchronizes NetXMS objects between server and client. After successful
* sync, subscribe client to object change notifications.
*
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public synchronized void syncObjects() throws IOException, NXCException {
syncObjects.acquireUninterruptibly();
NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_OBJECTS);
msg.setFieldInt16(NXCPCodes.VID_SYNC_COMMENTS, 1);
sendMessage(msg);
waitForRCC(msg.getMessageId());
waitForSync(syncObjects, commandTimeout * 10);
objectsSynchronized = true;
sendNotification(new SessionNotification(SessionNotification.OBJECT_SYNC_COMPLETED));
subscribe(CHANNEL_OBJECTS);
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method terminateAlarm.
/**
* Terminate alarm by helpdesk reference.
*
* @param helpdeskReference Identifier of alarm to be resolved.
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void terminateAlarm(final String helpdeskReference) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_TERMINATE_ALARM);
msg.setField(NXCPCodes.VID_HELPDESK_REF, helpdeskReference);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method bindAgentTunnel.
/**
* Bind agent tunnel to node
*
* @param tunnelId tunnel ID
* @param nodeId node ID
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void bindAgentTunnel(int tunnelId, long nodeId) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_BIND_AGENT_TUNNEL);
msg.setFieldInt32(NXCPCodes.VID_TUNNEL_ID, tunnelId);
msg.setFieldInt32(NXCPCodes.VID_NODE_ID, (int) nodeId);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method modifyScript.
/**
* Modify script. If scriptId is 0, new script will be created in library.
*
* @param scriptId script ID
* @param name script name
* @param source script source code
* @return script ID (newly assigned if new script was created)
* @throws IOException if socket or file I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public long modifyScript(long scriptId, String name, String source) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPDATE_SCRIPT);
msg.setFieldInt32(NXCPCodes.VID_SCRIPT_ID, (int) scriptId);
msg.setField(NXCPCodes.VID_NAME, name);
msg.setField(NXCPCodes.VID_SCRIPT_CODE, source);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
return response.getFieldAsInt64(NXCPCodes.VID_SCRIPT_ID);
}
Aggregations