use of org.netxms.client.datacollection.SimpleDciValue in project netxms by netxms.
the class AbstractNetworkMapView method openLinkDci.
/**
* Handler for opening network map dci on double click
*/
private void openLinkDci() {
final NetworkMapLink link = (NetworkMapLink) currentSelection.getFirstElement();
if (!link.hasDciData())
return;
new ConsoleJob("Open link dci job", this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#runInternal(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
DciValue[] values = session.getLastValues(link.getDciAsList());
final StringBuilder sb = new StringBuilder();
for (DciValue v : values) {
sb.append("&");
sb.append(Integer.toString(v instanceof SimpleDciValue ? ChartDciConfig.ITEM : ChartDciConfig.TABLE));
sb.append("@");
sb.append(Long.toString(v.getNodeId()));
sb.append("@");
sb.append(Long.toString(v.getId()));
sb.append("@");
sb.append(URLEncoder.encode(v.getDescription(), "UTF-8"));
sb.append("@");
sb.append(URLEncoder.encode(v.getName(), "UTF-8"));
}
runInUIThread(new Runnable() {
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
try {
getSite().getPage().showView(HistoricalGraphView.ID, sb.toString(), IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), "Error", String.format("Error opening view: %s", e.getLocalizedMessage()));
}
}
});
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#getErrorMessage()
*/
@Override
protected String getErrorMessage() {
return "Cannot open dci link historical graph view";
}
}.start();
}
use of org.netxms.client.datacollection.SimpleDciValue 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.SimpleDciValue in project netxms by netxms.
the class ShowLineChart method open.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.datacollection.api.DciOpenHandler#open(org.netxms.client.datacollection.DciValue)
*/
@Override
public boolean open(DciValue dci) {
if ((dci.getDcObjectType() != DataCollectionObject.DCO_TYPE_ITEM) || (dci.getDataType() == DataType.STRING))
return false;
final StringBuilder sb = new StringBuilder();
sb.append(uniqueId);
sb.append("&");
sb.append(Integer.toString(dci instanceof SimpleDciValue ? ChartDciConfig.ITEM : ChartDciConfig.TABLE));
sb.append("@");
sb.append(Long.toString(dci.getNodeId()));
sb.append("@");
sb.append(Long.toString(dci.getId()));
sb.append("@");
try {
sb.append(URLEncoder.encode(dci.getDescription(), "UTF-8"));
} catch (UnsupportedEncodingException e1) {
sb.append(Messages.get().ShowLineChart_DescriptionUnavailable);
}
sb.append("@");
try {
sb.append(URLEncoder.encode(dci.getName(), "UTF-8"));
} catch (UnsupportedEncodingException e1) {
sb.append("[");
sb.append(dci.getId());
sb.append("]");
}
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
window.getActivePage().showView(HistoricalGraphView.ID, sb.toString(), IWorkbenchPage.VIEW_ACTIVATE);
} catch (Exception e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().ShowLineChart_Error, String.format(Messages.get().ShowLineChart_ErrorOpeningView, e.getLocalizedMessage()));
}
return true;
}
Aggregations