I am trying to add graphs dynamically in the WPF code behind. This works fine, but I can't find a way to set the default interaction to zoom and the interactions to pan - is it possible to do this in code behind?
set graph properties in code behind
SampleQuantityMode.FiniteSample or ContinousSamples
Hello,
I have written simple code in MS which was earlier written in CVI
mRunningAiTask.Timing.SampleTimingType = SampleTimingType.SampleClock; mRunningAiTask.Timing.ConfigureSampleClock(string.Empty, mSamplesPerSecond, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples); mAiReader = new AnalogMultiChannelReader(mRunningAiTask.Stream); aReadBuffer = mAiReader.ReadMultiSample(mSamplesPerChannel);
mSamplesPerChannel > 1000, I only get 1000 samples in aReadBuffer. I have also tried with AsynCallback, the result is the same (with and without configuring SampleTimingType). HAve also changed timeout from default 10sec to -1.
However when the SampleQuantityMode is set to continous mode, I get the correct number of samples in ReadBuffer.
In CVI, I used FiniteSamples and it always returned correct number of samples. Although, I can live with it but still interested in knowing whet I am doing wrong.
Thanks and
Regards
Ricky
NationalInstruments.VisaNS.UsbSession.ControlIn - Actual Count?
I'm able to connect and communicate with my USBTMC instrument and retrieve information using UsbSession.ControlIn. The problem is that method doesn't return the actual bytes received like the old NI-VISA viUsbControlIn function did. In other words, the size of the byte array returned by UsbSession.ControlIn is simply the size I specified in the “length” parameter. How can I get the actual size like viUsbControlIn returned in the retCnt parameter?
I'm using Measurement Studio 2013 and Visual Studio 2012.
gaugedouble range binding
Hello,
i've a Problem by Setting the Range of an GaugeDouble with MVVM
Here is my Code that doesn't work. Hope anyboy can help me:
<ni:GaugeDouble Range="{Binding GaugeRange}" Value="{Binding Value}" Width="auto" /> and in my Viewmodel private Range<double> _GaugeRange; public Range<double> GaugeRange { get { return _GaugeRange; } set { _GaugeRange = value; NotifyPropertyChanged("GaugeRange"); } }
Thanks for your help
Do I have to install NI-DAQmx software or just .dlls file references are enough?
I have an application to measure voltage levels for which I only need to use NationalInstruments.DAQmx.dll and NationalInstrument.Common.dll files. If I have those files stored in a application directory and referenced from there will it serve the purpose? Or do I have to have NI-DAQmx software installed....whenever I install my application on a new computer?
NI-DMM speed
I'm using a PXI-4065 multimeter with MS Visual C#.NET 4.0 and NI-DMM. I have a test that requires a sort of closed-loop feedback system and I need to take DC voltage readings with an interval of every 5 ms or better (software controlled) for a period of 1 second. It needs to be software controlled so that the application can adjust a second parameter in response, ie. I can't use a multipoint measurement function. I have read all the NI-DMM documentation regarding aperture times, settling times, etc, and adjusted my function accordingly to read 4.5 digits, no settling time, and a discrete value of 0 for trigger delay (accuracy is not very important...I need the speed here). With the caveat of understanding that an RTOS might be better suited to do this, if money and time were no object, I need to make it work with what I've currently got.
I inserted a start time/finish time measurement before and after calling the read function (using DateTime.Now.Ticks; 1 tick = 100ns) and I'm measuring around 30 ms. Even with some processing overhead, I can't believe it should take that long to process this function with all the delay stuff on the meter turned off. Am I missing something? My NI-DMM function calls are as follows:
...
...
PXI4065_Session1.ConfigureMeasurementDigits(DmmMeasurementFunction.DCVolts, 300, 4.5);
PXI4065_Session1.Trigger.DelayAuto = false;
TimeSpan triggerDelay = new TimeSpan(0);
PXI4065_Session1.Trigger.Delay = triggerDelay;
PXI4065_Session1.Trigger.Source = DmmTriggerSource.Immediate;
PXI4065_Session1.Advanced.SettleTime = 0;
measuredReading = PXI4065_Session1.Measurement.Read();
...
...
Please help!
WPF GaugeDouble RangeFill
Hi
I am trying out the GaugeDouble wpf control. For the winforms control there is a RangeFills property. Is there a similar property for the GaugeDouble wpf control?
Kind regards
/Axel
Using external clocking to implement a frequency divider in .NET
Hi,
I've modified one of the example .NET projects to take an external clock over PFI0 and then output half the frequency on PFI1 by writing out a 0,1,0,1 ... waveform clocked by the PFI0.
My code is here:
This works great, but I have several questions:
1) The arguments to WriteMultiSamplePort are int32, does this mean that I'm changing all the PFI lines everytime I write to this? So bit 0 is PFI 0, bit 1 is PFI 1? Sorry for a basic question but I could not locate any documentation about what this function does.
2) When I feed it a small buffer (say 2 words) it fails with a buffer underrun for high external frequencies. Am I right in thinking that setting ConfigureSampleClock to ContinuousSamples+Rising Edge means that every rising edge it consumes one word from that buffer and copies it over the PFI pins? And then when the buffer is depleted it starts again from the start?
Finally, does this approach make sense? It works well enough, but I have a sneaking suspicion that theres a more elegant way to do this using counters or something like that :)
Thanks,
Mike
UI.WebForms.LED Displays in test website...does not display in production website
Hello,
I have an ASP.NET web application containing several WebForms.LED controls. When running the web site within Visual Studio, all of the controls display properly. However, after I publish the site to a production server, the controls are only partially visible (the caption appears, and the click interaction works properly). The behavior occurs in both IE 10 and Chrome. Could this be a bug in the LED control? Here is a screen capture of both:
Good LED (Debug Website):
Bad LED (Live Website):
Thank you for your assistance!!
-Eric
invisible plots still being drawn
Strange thing happens: when I've got multiple plots, and they all are hidden (Visibility=Collapsed), then when I output data, it is shown first, and then hidden (instead of not being drawn in the first place). When I've got at least one visible plot, then invisible ones aren't drawn as expected.
WiX and the MStudioDAQmx.2012 merge module
I am using Visual Studio 2012 + NI-DAQmx 9.7.5 (and tried 9.7.0 before that) and want to create an installer that includes the necessary merge modules MStudioDAQmx.2012.msm, its dependency MStudioCommon.2012.msm (and the Visual Studio C++ runtime) using WiX.
My problem is that the files contained in MStudioCommon.2012.msm seem to be installed in the GAC, where they belong, but the two files contained in MStudioDAQmx.2012.msm are copied into a folder "Module Retargetable Folder" in the installation directory - and that's where they IMHO do not belong. The difference between MStudioCommon.2012.msm and MStudioDAQmx.2012.msm is that, although both contain a custom action that rewrites the MergeRedirectFolder into a GAC folder,
MStudioCommon.2012.msm:
CA_RetargetDir.1C9B2EB5_9E34_4944_BA92_B30CCA4E9205 51 MergeRedirectFolder.1C9B2EB5_9E34_4944_BA92_B30CCA4E9205 [GAC.1C9B2EB5_9E34_4944_BA92_B30CCA4E9205]
MStudioDAQmx.2012.msm:
CA_RetargetDir.58D97DB1_77E6_476E_9B14_C9529BFA6F94 51 MergeRedirectFolder.58D97DB1_77E6_476E_9B14_C9529BFA6F94 [GAC.58D97DB1_77E6_476E_9B14_C9529BFA6F94]
Only MStudioCommon.2012.msm contains such a directory (GAC.1C9B2EB5_9E34_4944_BA92_B30CCA4E9205) in its directory table.
MergeRedirectFolder.1C9B2EB5_9E34_4944_BA92_B30CCA4E9205 TARGETDIR tdf6yy0s|Module Retargetable Folder
GAC.1C9B2EB5_9E34_4944_BA92_B30CCA4E9205 TARGETDIR boziguka|Global Assembly Cache
TARGETDIR SourceDir
MStudioDAQmx.2012.msm is missing such an entry.
MergeRedirectFolder.58D97DB1_77E6_476E_9B14_C9529BFA6F94 TARGETDIR tdf6yy0s|Module Retargetable Folder
TARGETDIR SourceDir
Is this the reason why the two files are installed in the wrong directory or am I doing something wrong? The corresponding parts of the WXS files are the following:
...
<Merge Id="VCRedist100" SourceFile="$(var.MergeModulesFilesDir)\Microsoft_VC100_CRT_x86.msm" DiskId="1" Language="0"/>
<Merge Id="MStudioCommon.2012" SourceFile="$(var.MergeModulesFilesDir)\MStudioCommon.2012.msm" DiskId="1" Language="0"/>
<Merge Id="MStudioDAQmx.2012" SourceFile="$(var.MergeModulesFilesDir)\MStudioDAQmx.2012.msm" DiskId="1" Language="0"/>
...
...
<Feature Id="VCRedist" Title="Visual C++ 10.0 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
<MergeRef Id="VCRedist100"/>
</Feature>
<Feature Id="MStudioCommon" Title="Measurement Studio Files" AllowAdvertise="no" Display="hidden" Level="1">
<MergeRef Id="MStudioCommon.2012"/>
<MergeRef Id="MStudioDAQmx.2012"/>
</Feature>
...
I searched the web for two days, but cannot figure out what my mistake is. Any help is appreciated.
Question about the " the application version require that assembly NationalInstruments"
Hi
I am using mesurement Studio with Visual Basic .NET (with GPIB USB Cable)
and
When I was running the program, I got error message.
"Unable to install or run the applcation. The application require that assembly NationalInstruments. MStudioCLM Version 13.0.40.188 be installed in the Global Assembly Cashe (GAC) first"
Therefore, I re-install for I-488.2 for WINCODWS, Ver 3.1.1
and I tried to run it again , but it didn't work.
I am not really sure to solve this problem
Is there anyway to solve this problem ?
Splitting PFI lines between multiple tasks
I'm trying to write to two different PFI lines. I'd rather have them in separate tasks because they'll need to have different length wavefroms, which would make updating them at the same time difficult. I tried this:
Basically I setup two identical tasks, one for line 1 and the other for line2. The first task works fine, however the second fails with:
A first chance exception of type 'NationalInstruments.DAQmx.DaqException' occurred in NationalInstruments.DAQmx.dll
Additional information: NI Platform Services: The specified resource is reserved. The operation could not be completed as specified.
Task Name: _unnamedTask<3>
Status Code: -50103
This is a little confusing to me. If I understand correctly, it should be possible to use two different PFI lines at the same time without interfering? I'm on a PCI-6731.
task parallel library
I am having an issue when using Task Parallel Library of .NET 4.0 along with ADO.Net.I am trying to execute two stored procedures parallel by creating two seperate tasks for each of them. The scenario is something like this.First stored procedure takes 20 sec to execute and the other takes around 12 sec.When I run the code,the time taken for execution is summation of these two time periods (i.e 20 + 12 = 32 sec).This is not what I am expecting.What I am assuming is that by the time first stored procedure has finished executing, the second one would have already finished and hence the total time taken for execution should be somewhere around 20 sec.I have also observed, that in my code,if i replace the ADO.Net section with just
Thread.Sleep(time), the result i get is expected i.e, if I set two threads of 20 and 12 sec, the program executes within 20 sec.This is the same behaviour I am trying to acheive using ADO.Net. I have also observered that, if I have these statements,
IAsyncResult result1 = cmd1.BeginExecuteReader();
IDataReader reader1 = cmd1.EndExecuteReader(result1);
for one of the stored procedure, I get expected behaviour.However, when I apply the same to the other stored procedure result,the program executes sequentially. I am confused about this behaviour. Hence, request any of you to help me in achieving the result I am looking for. I am attaching full code here.Please let me know where am I going wrong.
Code:
string connectionString1 = ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
string connectionString2 = ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString;
string connectionString3 = ConfigurationManager.ConnectionStrings["ConnectionString3"].ConnectionString;
List<int> results = new List<int>();
Dictionary<string, int> dict = new Dictionary<string, int>();
List<SqlDataReader> rdrs = new List<SqlDataReader>();
public List<int> returnSelect()
{
var taskIndex = -1;
var start = DateTime.Now;
Task[] tasks = new Task[]
{
Task.Factory.StartNew(() => PrintNumber1()),
Task.Factory.StartNew(() => PrintNumber2()),
Task.Factory.StartNew(() => PrintNumber3())
};
Dictionary<int, DateTime> taskList = new Dictionary<int, DateTime>();
while (tasks.Length > 0)
{
taskIndex = Task.WaitAny(tasks);
for (int i = 0; i < tasks.Count(); i++)
{
Console.Write("Array {0} | ", tasks[i].Id);
}
taskList.Add(tasks[taskIndex].Id, DateTime.Now);
tasks = tasks.Where((t) => t != tasks[taskIndex]).ToArray();
}
var end = DateTime.Now;
var diff = end - start;
int count = rdrs.Count;
int dcount = dict.Count;
return results;
}
//19
public void PrintNumber1()
{
SqlConnection con1 = new SqlConnection(connectionString1);
{
var start = DateTime.Now;
var copen = DateTime.Now;
var cclose = DateTime.Now;
int exSec = (cclose - copen).Seconds;
SqlCommand cmd1 = new SqlCommand("PS_Brand_level", con1);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@startdate", "6/25/2012");
cmd1.Parameters.AddWithValue("@enddate", "11/18/2012");
cmd1.Parameters.AddWithValue("@subbrands", "mybrands");
cmd1.Parameters.AddWithValue("@count", 11);
cmd1.Parameters.AddWithValue("@category", "a");
con1.Open();
IAsyncResult result1 = cmd1.BeginExecuteReader();
IDataReader reader1 = cmd1.EndExecuteReader(result1);
var end = DateTime.Now;
dict.Add((end - start).ToString(), 1);
}
/*var start = DateTime.Now;
Thread.Sleep(19000);
var end = DateTime.Now;
dict.Add((end - start).ToString(), 1);*/
}
//9
public void PrintNumber2()
{
SqlConnection con2 = new SqlConnection(connectionString2);
{
var start = DateTime.Now;
var copen = DateTime.Now;
con2.Open();
var cclose = DateTime.Now;
int exSec = (cclose - copen).Seconds;
DataSet dtPSPercentage = new DataSet();
SqlCommand cmd2 = new SqlCommand("Ps_Percentage", con2);
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.CommandTimeout = 100;
cmd2.Parameters.AddWithValue("@startdate", "6/25/2012");
cmd2.Parameters.AddWithValue("@enddate", "11/18/2012");
cmd2.Parameters.AddWithValue("@subbrands", "mybrands");
cmd2.Parameters.AddWithValue("@category", "a");
IAsyncResult result2 = cmd2.BeginExecuteReader();
IDataReader reader2 = cmd2.EndExecuteReader(result2);
var end = DateTime.Now;
dict.Add((end - start).ToString(), 2);
}
/*var start = DateTime.Now;
Thread.Sleep(9000);
var end = DateTime.Now;
dict.Add((end - start).ToString(), 2);*/
}
//12
public void PrintNumber3()
{
SqlConnection con3 = new SqlConnection(connectionString3);
{
var start = DateTime.Now;
var copen = DateTime.Now;
//con3.Open();
var cclose = DateTime.Now;
int exSec = (cclose - copen).Seconds;
SqlCommand cmd1 = new SqlCommand("Ps_Aggregated", con3);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@startdate", "6/25/2012");
cmd1.Parameters.AddWithValue("@enddate", "11/18/2012");
cmd1.Parameters.AddWithValue("@subbrands", "mybrands");
cmd1.Parameters.AddWithValue("@category", "a");
// IAsyncResult result1 = cmd1.BeginExecuteReader(CommandBehavior.SingleRow);
//SqlDataReader reader1 = cmd1.EndExecuteReader(result1);
var end = DateTime.Now;
dict.Add((end - start).ToString(), 3);
}
/*var start = DateTime.Now;
Thread.Sleep(12000);
var end = DateTime.Now;
dict.Add((end - start).ToString(), 3);*/
}
Thanks & Regards
strange plots on graphs
This is list of points I feed to the Graph:
[0]: {729000000,-50}
[1]: {756000000,-50}
[2]: {NaN,NaN}
[3]: {758000000,-50}
[4]: {768000000,-50}
[5]: {NaN,NaN}
[6]: {869000000,-50}
[7]: {894000000,-50}
[8]: {NaN,NaN}
[9]: {1525000000,-50}
[10]: {1559000000,-50}
[11]: {NaN,NaN}
[12]: {1930000000,-50}
[13]: {1995000000,-50}
[14]: {NaN,NaN}
[15]: {2110000000,-50}
[16]: {2170000000,-50}
[17]: {NaN,NaN}
[18]: {2180000000,-50}
[19]: {2200000000,-50}
[20]: {NaN,NaN}
[21]: {2496000000,-50}
[22]: {2690000000,-50}
[23]: {NaN,NaN}
But the plot is straight line instead of number of segments (see attachment). Tried both Vector and Raster rendering, without success.
MS 2013 WPF, VS 2010
Multiple Task Instances
I am using the NI-DAQ 6343 to create 4 analogue outputs. I have created a tiny generic wrapper class to wrap a single output channel. The class contains an instance of a
NationalInstruments.DAQmx.Task object. Thus, I will have four instances of class Task (as opposed to creating a single Task object with four AOChannels). Is there any (performance or other) drawback to this approach?
Output rate 100 Hz. Target platform, 1 GHz Win 7 Embedded.
Thanks.
Error Reading From DataSocket server Using DSReader Microsoft Visual C# .NET
I want to run the example program 'dsreader' from http://zone.ni.com/devzone/cda/epd/p/id/1139.
This example demonstrates how to use the Measurement Studio 6.0 CWDataSocket ActiveX control to create a DataSocket Reader/Writer in Visual C#. With this application, you can write a numeric value to a target source with the DataSocket Writer and read that value with the DataSocket Reader.
When I run dsreader in Visual C# .NET I get the following error:
Error 1 'AxCWDSLib.AxCWDataSocket' does not contain a definition for 'CtlUpdate' C:\........\DataSocket Reader\Form1.cs 301 13 DSReader
Any ideas would be welcome.
Ken35
Trigger waveform capture on change event
Hardware: NI USB-6525
IDE: Microsoft Visual Studio
Language: C#
System: Windows 7
The end goal is to determine the amount of time between two digital signal rising edges.
My attempt at generateing code:
1) Set up the event handeler to look for a rising edge on pin 0.
2) Once a rising edge happens, capture digital data for 2 seconds from pins 0 and 1.
3) Read waveform data from USB device.
4) Calculate time between rising edges.
First off I have looked through the examples from National Instruments, but I cannot get these to do what I need for various reasons. Using callback functions with the begin and end waveform captures just seem to run too sluggish when i want to capture data for 2 seconds.
In the code I have attached, I have not done step 4 above. I am just trying to read the waveform, however the waveform does not seem to populate when the change event occurs. Any reason why the waveform will not populate with the specified number of samples? I am able to read single samples or multiple samples on a single line, however I need to read a "waveform" to get all the information I need for the timing calculation.
Attached is the C# code.
Error about retrieving dependency MStudioCommon.2012
I am developing applcaiton based on visual basic .net and I would like to build installation package by installation shield.
However, when I built the setup project, I am getting an error , so i can't build install package.
When I was building setup project,
For example,
ISEXP : warning : -6245: One or more of the project's components contain .NET properties that require the .NET Framework. It is recommended that the release include the .NET Framework.
ISEXP : warning : -6248: Could not find dependent file rscmwgg_64.dll, or one of its dependencies of component Interop.rscmwgg.dll
ISEXP : warning : -6248: Could not find dependent file rscmwgg_64.dll, or one of its dependencies of component Interop.rscmwgg.dll1
Adding merge module 'Visual C++ 10.0 CRT (x86)' that is a dependency of component 'NationalInstruments.UI.Styles3D.dll'
Adding merge module 'Visual C++ 10.0 CRT (x86)' that is a dependency of component 'NationalInstruments.UI.Styles3D.dll1'
Adding merge module 'NI Measurement Studio Visa Support.2012' that is a dependency of component 'WindowsApplication2.exe'
Adding merge module 'NI Measurement Studio Visa Support.2012' that is a dependency of component 'WindowsApplication2.exe4'
ISEXP : error : -4072: Error retrieving dependency MStudioCommon.2012.1C9B2EB5_9E34_4944_BA92_B30CCA4E9205:1033 of C:\Program Files (x86)\Common Files\Merge Modules\MStudioVisa.2012.msm
ISEXP : error : -4072: Error retrieving dependency MStudioCommon.2012.1C9B2EB5_9E34_4944_BA92_B30CCA4E9205:1033 of C:\Program Files (x86)\Common Files\Merge Modules\MStudioVisa.2012.msm
Merging NI Measurement Studio Visa Support.2012: C:\Program Files (x86)\Common Files\Merge Modules\MStudioVisa.2012.msm
I was assuming that compiler couldn't find file " rscmwgg_64.dll". Therefore, I install driver rscmwgg_64. However, i am still getting error.
Therefore, I tried to remove reference of "rscmwgg_64.dll" from my project because I am not using this driver anymore.(but it still doesn't work.)
Therefore, I am assuming that problem might relate with
I am not sure how to solve this problem MStudioVisa.2012.msm(But, not sure about it..)
does anybody know how to solve this error ?
thanks
WPF Scatter Plot
I currently have an ObservableCollection<Point[]> which i am binding to the datasource property of a graph. This plots fine, but the points in each point array are joined by a line. Is there a way to turn the line off and just show point markers. If so how? And how might you format the markers?
Thanks