Search in sources :

Example 1 with SimpleDciValue

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DciValue(org.netxms.client.datacollection.DciValue) SimpleDciValue(org.netxms.client.datacollection.SimpleDciValue) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) SimpleDciValue(org.netxms.client.datacollection.SimpleDciValue) PartInitException(org.eclipse.ui.PartInitException) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with SimpleDciValue

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;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) DciValue(org.netxms.client.datacollection.DciValue) SimpleDciValue(org.netxms.client.datacollection.SimpleDciValue) SimpleDciValue(org.netxms.client.datacollection.SimpleDciValue) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 3 with SimpleDciValue

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;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SimpleDciValue(org.netxms.client.datacollection.SimpleDciValue) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

SimpleDciValue (org.netxms.client.datacollection.SimpleDciValue)3 DciValue (org.netxms.client.datacollection.DciValue)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1 NXCPMessage (org.netxms.base.NXCPMessage)1 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)1 AccessPoint (org.netxms.client.objects.AccessPoint)1 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1