implemented GET_DCI_THRESHOLDS API call
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 28 May 2010 12:32:33 +0000 (12:32 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 28 May 2010 12:32:33 +0000 (12:32 +0000)
20 files changed:
include/nms_cscp.h
include/nxclapi.h
netxms.sln
src/db/dbdrv/mysql/mysql.vcproj
src/java/netxms-base/src/main/java/org/netxms/base/NXCPCodes.java
src/java/netxms-client/src/main/java/org/netxms/client/NXCSession.java
src/java/netxms-client/src/main/java/org/netxms/client/datacollection/DataCollectionConfiguration.java
src/java/netxms-client/src/main/java/org/netxms/client/datacollection/Threshold.java
src/java/netxms-client/src/test/java/org/netxms/client/DataCollectionTest.java
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/views/AlarmBrowser.java
src/java/netxms-eclipse/ObjectBrowser/plugin.xml
src/java/netxms-eclipse/ObjectBrowser/src/org/netxms/ui/eclipse/objectbrowser/views/ObjectBrowser.java
src/java/netxms-eclipse/core/src/org/netxms/ui/eclipse/console/perspectives/DefaultPerspective.java
src/libexpat/libexpat/libexpat.vcproj
src/libnetxms/nxcp.cpp
src/libnxcl/datacoll.cpp
src/server/core/dcitem.cpp
src/server/core/session.cpp
src/server/include/nms_core.h
src/server/include/nms_dcoll.h

index 1a5967b..42b53eb 100644 (file)
@@ -455,6 +455,7 @@ typedef struct
 #define CMD_FORWARD_EVENT           0x00EB
 #define CMD_GET_USM_CREDENTIALS     0x00EC
 #define CMD_UPDATE_USM_CREDENTIALS  0x00ED
+#define CMD_GET_DCI_THRESHOLDS      0x00EE
 
 
 //
index 7d88dd0..d1a53b7 100644 (file)
@@ -1900,6 +1900,8 @@ DWORD LIBNXCL_EXPORTABLE NXCGetDCIEventsList(NXC_SESSION hSession, DWORD dwObjec
                                              DWORD **ppdwList, DWORD *pdwListSize);
 DWORD LIBNXCL_EXPORTABLE NXCGetDCIInfo(NXC_SESSION hSession, DWORD dwNodeId,
                                                                                                        DWORD dwItemId, NXC_DCI *pInfo);
+DWORD LIBNXCL_EXPORTABLE NXCGetDCIThresholds(NXC_SESSION hSession, DWORD dwNodeId, DWORD dwItemId,
+                                                                                                                       NXC_DCI_THRESHOLD **ppList, DWORD *pdwSize);
 
 /** Container categories **/
 DWORD LIBNXCL_EXPORTABLE NXCLoadCCList(NXC_SESSION hSession, NXC_CC_LIST **ppList);
index 4d27f99..924e719 100644 (file)
@@ -983,11 +983,13 @@ Global
                {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Win32
                {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Debug|Win32.ActiveCfg = Debug|Win32
                {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Debug|Win32.Build.0 = Debug|Win32
-               {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Debug|x64.ActiveCfg = Debug|Win32
+               {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Debug|x64.ActiveCfg = Debug|x64
+               {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Debug|x64.Build.0 = Debug|x64
                {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Win32
                {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Release|Win32.ActiveCfg = Release|Win32
                {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Release|Win32.Build.0 = Release|Win32
-               {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Release|x64.ActiveCfg = Release|Win32
+               {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Release|x64.ActiveCfg = Release|x64
+               {7BEDC9BF-E345-4BD6-B063-C3564963036E}.Release|x64.Build.0 = Release|x64
                {AA515A35-366D-4EBF-A927-A017A841C48D}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|x64
                {AA515A35-366D-4EBF-A927-A017A841C48D}.Debug|Win32.ActiveCfg = Debug|Win32
                {AA515A35-366D-4EBF-A927-A017A841C48D}.Debug|Win32.Build.0 = Debug|Win32
index aab543f..7e2c903 100644 (file)
@@ -11,6 +11,9 @@
                <Platform\r
                        Name="Win32"\r
                />\r
+               <Platform\r
+                       Name="x64"\r
+               />\r
        </Platforms>\r
        <ToolFiles>\r
        </ToolFiles>\r
                                Name="VCPostBuildEventTool"\r
                        />\r
                </Configuration>\r
+               <Configuration\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..\..\..\include"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MYSQL_EXPORTS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="libmysql.lib"\r
+                               OutputFile="$(OutDir)\$(ProjectName).ddr"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="2"\r
+                               TargetMachine="17"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories="..\..\..\..\include"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MYSQL_EXPORTS"\r
+                               RuntimeLibrary="2"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="libmysql.lib"\r
+                               OutputFile="$(OutDir)\$(ProjectName).ddr"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="2"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="17"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
        </Configurations>\r
        <References>\r
        </References>\r
index 13586df..ad0b29e 100644 (file)
@@ -265,6 +265,7 @@ public final class NXCPCodes
        public static final int CMD_FORWARD_EVENT           = 0x00EB;\r
        public static final int CMD_GET_USM_CREDENTIALS     = 0x00EC;\r
        public static final int CMD_UPDATE_USM_CREDENTIALS  = 0x00ED;\r
+       public static final int CMD_GET_DCI_THRESHOLDS      = 0x00EE;\r
        \r
        // Variable codes\r
        public static final long VID_LOGIN_NAME              = 1;\r
index 0b8b0ab..6ce66b1 100644 (file)
@@ -49,6 +49,7 @@ import org.netxms.client.datacollection.DataCollectionItem;
 import org.netxms.client.datacollection.DciData;\r
 import org.netxms.client.datacollection.DciDataRow;\r
 import org.netxms.client.datacollection.DciValue;\r
+import org.netxms.client.datacollection.Threshold;\r
 import org.netxms.client.events.Event;\r
 import org.netxms.client.events.EventProcessingPolicy;\r
 import org.netxms.client.events.EventProcessingPolicyRule;\r
@@ -1868,21 +1869,48 @@ public class NXCSession
 \r
                return data;\r
        }\r
+       \r
+       /**\r
+        * Get list of thresholds configured for given DCI\r
+        * \r
+        * @param nodeId Node object ID\r
+        * @param dciId DCI ID\r
+        * @return List of configured thresholds\r
+        * @throws IOException if socket I/O error occurs\r
+        * @throws NXCException if NetXMS server returns an error or operation was timed out\r
+        */\r
+       public Threshold[] getThresholds(final long nodeId, final long dciId) throws IOException, NXCException\r
+       {\r
+               final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_DCI_THRESHOLDS);\r
+               msg.setVariableInt32(NXCPCodes.VID_OBJECT_ID, (int)nodeId);\r
+               msg.setVariableInt32(NXCPCodes.VID_DCI_ID, (int)dciId);\r
+               sendMessage(msg);\r
+               \r
+               final NXCPMessage response = waitForRCC(msg.getMessageId());\r
+               int count = response.getVariableAsInteger(NXCPCodes.VID_NUM_THRESHOLDS);\r
+               final Threshold[] list = new Threshold[count];\r
+               \r
+               long varId = NXCPCodes.VID_DCI_THRESHOLD_BASE;\r
+               for(int i = 0; i < count; i++)\r
+               {\r
+                       list[i] = new Threshold(response, varId);\r
+                       varId += 10;\r
+               }\r
+               \r
+               return list;\r
+       }\r
 \r
        /**\r
         * Create object\r
         * \r
-        * @param data\r
-        *           Object creation data\r
+        * @param data Object creation data\r
         * @return ID of new object\r
-        * @throws IOException\r
-        *            if socket I/O error occurs\r
-        * @throws NXCException\r
-        *            if NetXMS server returns an error or operation was timed out\r
+        * @throws IOException if socket I/O error occurs\r
+        * @throws NXCException if NetXMS server returns an error or operation was timed out\r
         */\r
        public long createObject(final NXCObjectCreationData data) throws IOException, NXCException\r
        {\r
-               NXCPMessage msg = newMessage(NXCPCodes.CMD_CREATE_OBJECT);\r
+               final NXCPMessage msg = newMessage(NXCPCodes.CMD_CREATE_OBJECT);\r
 \r
                // Common attributes\r
                msg.setVariableInt32(NXCPCodes.VID_PARENT_ID, (int) data.getParentId());\r
@@ -1904,7 +1932,7 @@ public class NXCSession
                }\r
 \r
                sendMessage(msg);\r
-               NXCPMessage response = waitForRCC(msg.getMessageId());\r
+               final NXCPMessage response = waitForRCC(msg.getMessageId());\r
                return response.getVariableAsInt64(NXCPCodes.VID_OBJECT_ID);\r
        }\r
 \r
index a252cc2..5b8cc0f 100644 (file)
@@ -136,7 +136,7 @@ public class DataCollectionConfiguration
        /**\r
         * Modify data collection item.\r
         * \r
-        * @param itemId Data collection item\r
+        * @param item Data collection item\r
         * @throws IOException if socket I/O error occurs\r
         * @throws NXCException if NetXMS server returns an error or operation was timed out\r
         */\r
index 00c38a5..1e21915 100644 (file)
@@ -43,7 +43,7 @@ public class Threshold
         * @param msg NXCP message\r
         * @param baseId Base variable ID for this threshold in message\r
         */\r
-       protected Threshold(final NXCPMessage msg, final long baseId)\r
+       public Threshold(final NXCPMessage msg, final long baseId)\r
        {\r
                long varId = baseId;\r
                \r
index cb878e7..f5b337a 100644 (file)
  */\r
 package org.netxms.client;\r
 \r
+import org.netxms.client.datacollection.DataCollectionConfiguration;\r
 import org.netxms.client.datacollection.DataCollectionItem;\r
 import org.netxms.client.datacollection.DciValue;\r
+import org.netxms.client.datacollection.Threshold;\r
 \r
 /**\r
  * @author Victor\r
@@ -27,11 +29,13 @@ import org.netxms.client.datacollection.DciValue;
  */\r
 public class DataCollectionTest extends SessionTest\r
 {\r
+       private static final long nodeId = 12;\r
+       \r
        public void testGetLastValues() throws Exception\r
        {\r
                final NXCSession session = connect();\r
                \r
-               DciValue[] list = session.getLastValues(12);\r
+               DciValue[] list = session.getLastValues(nodeId);\r
                assertEquals(true, list.length > 0);\r
                \r
                boolean statusFound = false;\r
@@ -42,4 +46,23 @@ public class DataCollectionTest extends SessionTest
                \r
                session.disconnect();\r
        }\r
+\r
+       public void testGetThresholds() throws Exception\r
+       {\r
+               final NXCSession session = connect();\r
+               \r
+               DataCollectionConfiguration dc = session.openDataCollectionConfiguration(nodeId);\r
+               final long dciId = dc.createItem();\r
+               DataCollectionItem dci = dc.findItem(dciId);\r
+               dci.setName("TEST");\r
+               dc.modifyItem(dciId);\r
+               \r
+               Threshold[] thresholds = session.getThresholds(nodeId, dciId);\r
+               assertNotNull(thresholds);\r
+               assertEquals(0, thresholds.length);\r
+\r
+               dc.deleteItem(dciId);\r
+               dc.close();\r
+               session.disconnect();\r
+       }\r
 }\r
index 762d7aa..0612269 100644 (file)
  */\r
 package org.netxms.ui.eclipse.alarmviewer.views;\r
 \r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.layout.FormAttachment;\r
 import org.eclipse.swt.layout.FormData;\r
 import org.eclipse.swt.layout.FormLayout;\r
 import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.ISelectionListener;\r
+import org.eclipse.ui.ISelectionService;\r
+import org.eclipse.ui.IWorkbenchPart;\r
 import org.eclipse.ui.part.ViewPart;\r
+import org.netxms.client.objects.GenericObject;\r
 import org.netxms.ui.eclipse.alarmviewer.widgets.AlarmList;\r
 \r
 /**\r
@@ -35,6 +41,8 @@ public class AlarmBrowser extends ViewPart
        public static final String ID = "org.netxms.ui.eclipse.alarmviewer.view.alarm_browser";\r
        \r
        private AlarmList alarmView;\r
+       private ISelectionService selectionService;\r
+       private ISelectionListener selectionListener;\r
 \r
        /**\r
         * \r
@@ -60,6 +68,23 @@ public class AlarmBrowser extends ViewPart
                fd.right = new FormAttachment(100, 0);\r
                fd.bottom = new FormAttachment(100, 0);\r
                alarmView.setLayoutData(fd);\r
+               \r
+               selectionService = getSite().getWorkbenchWindow().getSelectionService();\r
+               selectionListener = new ISelectionListener() {\r
+                       @Override\r
+                       public void selectionChanged(IWorkbenchPart part, ISelection selection)\r
+                       {\r
+                               if ((selection instanceof IStructuredSelection) && !selection.isEmpty())\r
+                               {\r
+                                       Object object = ((IStructuredSelection)selection).getFirstElement();\r
+                                       if (object instanceof GenericObject)\r
+                                       {\r
+                                               alarmView.setRootObject(((GenericObject)object).getObjectId());\r
+                                       }\r
+                               }\r
+                       }\r
+               };\r
+               selectionService.addSelectionListener(selectionListener);\r
        }\r
 \r
        /* (non-Javadoc)\r
index ea99c5a..4212db9 100644 (file)
@@ -8,7 +8,7 @@
             allowMultiple="false"\r
             icon="icons/object_browser.png"\r
             class="org.netxms.ui.eclipse.objectbrowser.views.ObjectBrowser"\r
-            id="org.netxms.ui.eclipse.objectbrowser.view.object_browser">\r
+            id="org.netxms.ui.eclipse.view.navigation.objectbrowser">\r
       </view>\r
    </extension>\r
 \r
index d32c861..81b95cb 100644 (file)
@@ -29,7 +29,7 @@ import org.netxms.ui.eclipse.shared.NXMCSharedData;
  */\r
 public class ObjectBrowser extends ViewPart\r
 {\r
-       public static final String ID = "org.netxms.ui.eclipse.objectbrowser.view.object_browser"; //$NON-NLS-1$\r
+       public static final String ID = "org.netxms.ui.eclipse.view.navigation.objectbrowser"; //$NON-NLS-1$\r
        \r
        private ObjectTree objectTree;\r
 \r
@@ -221,6 +221,8 @@ public class ObjectBrowser extends ViewPart
                \r
                createMenu();\r
                createPopupMenu();\r
+               \r
+               getSite().setSelectionProvider(objectTree.getTreeViewer());\r
        }\r
 \r
        public void setFocus() \r
index 4032da0..62277ce 100644 (file)
@@ -33,8 +33,9 @@ public class DefaultPerspective implements IPerspectiveFactory
        @Override\r
        public void createInitialLayout(IPageLayout layout)\r
        {\r
-               layout.setEditorAreaVisible(false);\r
-               layout.addView("org.netxms.ui.eclipse.objectbrowser.view.object_browser", IPageLayout.LEFT, 0, "");\r
-               layout.addView("org.netxms.ui.eclipse.alarmviewer.view.alarm_browser", IPageLayout.RIGHT, 0.25f, "org.netxms.ui.eclipse.objectbrowser.view.object_browser");\r
+               //layout.setEditorAreaVisible(false);\r
+               \r
+               layout.addView("org.netxms.ui.eclipse.view.navigation.objectbrowser", IPageLayout.LEFT, 0, "");\r
+               //layout.addView("org.netxms.ui.eclipse.alarmviewer.view.alarm_browser", IPageLayout.RIGHT, 0.25f, "org.netxms.ui.eclipse.objectbrowser.view.object_browser");\r
        }\r
 }\r
index 65d3bb7..e133dce 100644 (file)
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="2"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
                                PreprocessorDefinitions="COMPILED_FROM_DSP"\r
-                               RuntimeLibrary="2"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="false"\r
+                               Detect64BitPortabilityProblems="true"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               LinkIncremental="1"\r
+                               LinkIncremental="2"\r
                                ModuleDefinitionFile="libexpat.def"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
                                PreprocessorDefinitions="COMPILED_FROM_DSP"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
                                ModuleDefinitionFile="libexpat.def"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               TargetMachine="17"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
index 1435bf0..e73952c 100644 (file)
@@ -280,10 +280,11 @@ TCHAR LIBNETXMS_EXPORTABLE *NXCPMessageCodeName(WORD wCode, TCHAR *pszBuffer)
                _T("CMD_GET_SERVER_FILE"),
                _T("CMD_FORWARD_EVENT"),
                _T("CMD_GET_USM_CREDENTIALS"),
-               _T("CMD_UPDATE_USM_CREDENTIALS")
+               _T("CMD_UPDATE_USM_CREDENTIALS"),
+               _T("CMD_GET_DCI_THRESHOLDS")
    };
 
-   if ((wCode >= CMD_LOGIN) && (wCode <= CMD_UPDATE_USM_CREDENTIALS))
+   if ((wCode >= CMD_LOGIN) && (wCode <= CMD_GET_DCI_THRESHOLDS))
       _tcscpy(pszBuffer, pszMsgNames[wCode - CMD_LOGIN]);
    else
       _sntprintf(pszBuffer, 64, _T("CMD_0x%04X"), wCode);
index d5dee0f..754499a 100644 (file)
@@ -595,6 +595,60 @@ DWORD LIBNXCL_EXPORTABLE NXCQueryParameter(NXC_SESSION hSession, DWORD dwNodeId,
 }
 
 
+//
+// Get threshold list for given DCI
+//
+
+DWORD LIBNXCL_EXPORTABLE NXCGetDCIThresholds(NXC_SESSION hSession, DWORD dwNodeId, DWORD dwItemId,
+                                                                                                                       NXC_DCI_THRESHOLD **ppList, DWORD *pdwSize)
+{
+   CSCPMessage msg, *pResponse;
+   DWORD i, dwId, dwRqId, dwResult;
+
+       CHECK_SESSION_HANDLE();
+
+       *ppList = NULL;
+       *pdwSize = 0;
+
+   dwRqId = ((NXCL_Session *)hSession)->CreateRqId();
+
+   msg.SetCode(CMD_GET_DCI_THRESHOLDS);
+   msg.SetId(dwRqId);
+   msg.SetVariable(VID_OBJECT_ID, dwNodeId);
+       msg.SetVariable(VID_DCI_ID, dwItemId);
+   ((NXCL_Session *)hSession)->SendMsg(&msg);
+
+   pResponse = ((NXCL_Session *)hSession)->WaitForMessage(CMD_REQUEST_COMPLETED, dwRqId);
+   if (pResponse != NULL)
+   {
+      dwResult = pResponse->GetVariableLong(VID_RCC);
+      if (dwResult == RCC_SUCCESS)
+               {
+                       *pdwSize = pResponse->GetVariableLong(VID_NUM_THRESHOLDS);
+                       *ppList = (NXC_DCI_THRESHOLD *)malloc(sizeof(NXC_DCI_THRESHOLD) * (*pdwSize));
+                       for(i = 0, dwId = VID_DCI_THRESHOLD_BASE; i < *pdwSize; i++, dwId++)
+                       {
+                               (*ppList)[i].dwId = pResponse->GetVariableLong(dwId++);
+                               (*ppList)[i].dwEvent = pResponse->GetVariableLong(dwId++);
+                               (*ppList)[i].dwRearmEvent = pResponse->GetVariableLong(dwId++);
+                               (*ppList)[i].wFunction = pResponse->GetVariableShort(dwId++);
+                               (*ppList)[i].wOperation = pResponse->GetVariableShort(dwId++);
+                               (*ppList)[i].dwArg1 = pResponse->GetVariableLong(dwId++);
+                               (*ppList)[i].dwArg2 = pResponse->GetVariableLong(dwId++);
+                               (*ppList)[i].nRepeatInterval = (LONG)pResponse->GetVariableLong(dwId++);
+                               pResponse->GetVariableStr(dwId++, (*ppList)[i].szValue, MAX_STRING_VALUE);
+                       }
+               }
+      delete pResponse;
+   }
+   else
+   {
+      dwResult = RCC_TIMEOUT;
+   }
+   return dwResult;
+}
+
+
 //
 // Get last values for all DCIs of selected node
 //
index e425e88..73e3c5d 100644 (file)
@@ -2170,3 +2170,23 @@ BOOL DCItem::testTransformation(const TCHAR *script, const TCHAR *value, TCHAR *
    }
        return success;
 }
+
+
+//
+// Fill NXCP message with thresholds
+//
+
+void DCItem::fillMessageWithThresholds(CSCPMessage *msg)
+{
+       DWORD i, id;
+
+       lock();
+
+       msg->SetVariable(VID_NUM_THRESHOLDS, m_dwNumThresholds);
+       for(i = 0, id = VID_DCI_THRESHOLD_BASE; i < m_dwNumThresholds; i++, id += 10)
+       {
+               m_ppThresholdList[i]->createMessage(msg, id);
+       }
+
+       unlock();
+}
index 8fc3920..1c6a494 100644 (file)
@@ -1050,6 +1050,9 @@ void ClientSession::ProcessingThread(void)
                        case CMD_GET_DCI_INFO:
                                SendDCIInfo(pMsg);
                                break;
+                       case CMD_GET_DCI_THRESHOLDS:
+                               sendDCIThresholds(pMsg);
+                               break;
          case CMD_GET_DCI_EVENTS_LIST:
             sendDCIEventList(pMsg);
             break;
@@ -3144,6 +3147,58 @@ void ClientSession::CopyDCI(CSCPMessage *pRequest)
 }
 
 
+//
+// Send list of thresholds for DCI
+//
+
+void ClientSession::sendDCIThresholds(CSCPMessage *request)
+{
+   CSCPMessage msg;
+   NetObj *object;
+
+   // Prepare response message
+   msg.SetCode(CMD_REQUEST_COMPLETED);
+   msg.SetId(request->GetId());
+
+   // Get node id and check object class and access rights
+   object = FindObjectById(request->GetVariableLong(VID_OBJECT_ID));
+   if (object != NULL)
+   {
+      if (object->CheckAccessRights(m_dwUserId, OBJECT_ACCESS_READ))
+      {
+                       if (object->Type() == OBJECT_NODE)
+                       {
+                               DCItem *dci = ((Node *)object)->GetItemById(request->GetVariableLong(VID_DCI_ID));
+                               if (dci != NULL)
+                               {
+                                       dci->fillMessageWithThresholds(&msg);
+                                       msg.SetVariable(VID_RCC, RCC_SUCCESS);
+                               }
+                               else
+                               {
+                                       msg.SetVariable(VID_RCC, RCC_INVALID_DCI_ID);
+                               }
+         }
+         else
+         {
+            msg.SetVariable(VID_RCC, RCC_INCOMPATIBLE_OPERATION);
+         }
+      }
+      else
+      {
+         msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+      }
+   }
+   else  // No object with given ID
+   {
+               msg.SetVariable(VID_RCC, RCC_INVALID_OBJECT_ID);
+   }
+
+   // Send response
+   sendMessage(&msg);
+}
+
+
 //
 // Get collected data
 //
@@ -3202,7 +3257,6 @@ void ClientSession::GetCollectedData(CSCPMessage *pRequest)
 
             // Get item's data type to determine actual row size
             iType = ((Node *)pObject)->GetItemType(dwItemId);
-//DWORD s=GetTickCount();
             // Create database-dependent query for fetching N rows
             switch(g_nDBSyntax)
             {
@@ -3226,7 +3280,6 @@ void ClientSession::GetCollectedData(CSCPMessage *pRequest)
                   break;
             }
             hResult = DBSelect(g_hCoreDB, szQuery);
-//printf("[%d] **** QUERY DONE\n", GetTickCount() - s);
             if (hResult != NULL)
             {
                // Send CMD_REQUEST_COMPLETED message
@@ -3277,7 +3330,6 @@ void ClientSession::GetCollectedData(CSCPMessage *pRequest)
                }
                DBFreeResult(hResult);
                pData->dwNumRows = htonl(dwNumRows);
-//printf("[%d] **** %d ROWS\n", GetTickCount() - s, dwNumRows);
 
                // Prepare and send raw message with fetched data
                m_pSendQueue->Put(
index 9075597..c101798 100644 (file)
@@ -557,6 +557,7 @@ private:
        void getServerLogQueryData(CSCPMessage *request);
        void sendUsmCredentials(DWORD dwRqId);
        void updateUsmCredentials(CSCPMessage *pRequest);
+       void sendDCIThresholds(CSCPMessage *request);
 
 public:
    ClientSession(SOCKET hSocket, DWORD dwHostAddr);
index f211fbd..8c4aba9 100644 (file)
@@ -128,6 +128,8 @@ public:
    DWORD getId() { return m_id; }
    DWORD getEventCode() { return m_eventCode; }
    DWORD getRearmEventCode() { return m_rearmEventCode; }
+       int getFunction() { return m_function; }
+       int getOperation() { return m_operation; }
    const char *getStringValue() { return m_value.String(); }
    BOOL isReached() { return m_isReached; }
        
@@ -271,6 +273,7 @@ public:
 
    void createMessage(CSCPMessage *pMsg);
    void updateFromMessage(CSCPMessage *pMsg, DWORD *pdwNumMaps, DWORD **ppdwMapIndex, DWORD **ppdwMapId);
+       void fillMessageWithThresholds(CSCPMessage *msg);
 
    void deleteExpiredData();
        BOOL deleteAllData();