Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

System Clock display on Graph Sample Code

Does anyone have any sample code of displaying the system clock on a graph along the x-axis as
the y-axis function changes?  I've fiddled with this and have not been able to get it to work.  This is an Measurement Studio
application using Visual C++ 2005.
0 Kudos
Message 1 of 9
(5,113 Views)
When plotting your data using the PlotY function, you can pass in two additional values, a DateTime start, and a TimeSpan increment.  The start variable is the timestamp of the first data point that is plotted, and the increment is the amount of time between each successive data point.  An example of this is shown below:

            TimeSpan myTimeSpan = new TimeSpan(100000);
            myGraph.PlotY(DataArray, DateTime.Now, myTimeSpan);
   

Additionally, you will have to format the waveform graph to display a time instead of an integer on the X Axis.  To do this:
    1. Click on the Waveform Graph Properties Arrow
    2. In the XAxis section, click on the ... button on the Label Format field.
    3. In the Category drop down box, select DateTime, and then select the Time or Date format that you would like to be shown.
    4. Click OK.
0 Kudos
Message 2 of 9
(5,069 Views)
Are there Includes that I need to invoke TimeSpan and DateTime.Now?  I'm using Measurement Studio VC2005
version 8.1.2
0 Kudos
Message 3 of 9
(5,063 Views)
The TimeSpan and the DateTime functions are contained in the System Namespace.  I found this information by searching the Microsoft Visual Studio Help. You will need the following include statement:

#using <mscorlib.dll>
0 Kudos
Message 4 of 9
(5,058 Views)
This does not seem to be working for me.  I keep getting the following error when I compile:


fatal error C1190: managed targeted code requires a '/clr' option

0 Kudos
Message 5 of 9
(5,050 Views)
Hi tonyp,

I did a quick search on google of the error that you posted and the very first result returned a link to the Microsoft Developer Network with information about this error.  http://msdn2.microsoft.com/en-us/library/34yyz778(vs.71).aspx.

  From there, I was able to find what the '/clr' option is.  The /clr compiler option enables the use of Managed Extensions for C++ and creates an output file that will require the .NET Framework common language runtime at run time.

According to the Microsoft Website, to set this compiler option in the Visual Studio development environment
  1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
  2. Click the Configuration Properties folder.
  3. Click the General property page.
  4. Modify the Use Managed Extensions property.
For more information about the 'clr' option, please visit http://msdn2.microsoft.com/en-us/library/k8d11d4s(VS.71).aspx
0 Kudos
Message 6 of 9
(5,019 Views)
Hi tonyp,
 
I assume based off your posts that since your are using Visual C++ 2005 you are probably using MFC which means you are using our ActiveX UI components. Now, if you were using managed C++, then you could uses our .NET assemblies but I don't think you are. Thus, you don't have to do what Jonathan is suggesting.
 
Instead, you can set the FormatString property either during runtime or design time for your axes. Open up the Property Pages for the graph, select the Format category, and then choose the Time style.  You may want the Date style, but I will leave that up to you. See the attached snapshot, Format Option.jpg
 
Once you have set that property, you need to choose your intervals in terms of what time intervals you want to display. See this post for more information as it gives some code snippets you can use.  Also, its important to note how the Date/Time values are displayed and implemented. Refer to the CNiAxis main help topic and see the Note in the overview section about date/time. 
 
Hope this helps!
 
Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 7 of 9
(5,000 Views)
Thanks Jonathan

I did get this to work.  The mistake I was making was passing the system time to the ChartXY as opposed to the variant time.
Now I just convert the systemtime to the variant time and pass that as the X-Axis in the ChartXY(double, double) and after formating the
properties of the graph for day and time I get the complete date and time updating as the plot goes along.  Again Thanks.
0 Kudos
Message 8 of 9
(4,997 Views)

Sound good tony.

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 9 of 9
(4,994 Views)