Quantcast
Channel: Measurement Studio for .NET Languages topics
Viewing all 1999 articles
Browse latest View live

Reading flatten string from Network Variable

$
0
0

We have some RT targets writing cluster data to a Network Variable on a Windows machine. The variable type is string. Data is written using "Flatten To String". Everything worked fine when reading the variable and unflatten the value in Labview.

 

Now, we tried the read task from Measurement Studio .NET. Unfortunately, the NetworkVariableReader always returns an empty string. I'm afraid that marshalling the "binary ANSI string" is not supported. I can't find any limitations for strings in the Measurement Studio docs. Furthermore, passing a flatten string through a Labview .NET Interop Assembly works in both ways.

 

Final question: How do I read a flatten string from a Network Variable in .NET? Refactoring RT code is not possible.


Distribution: Pre Requisites for Target Machine.

$
0
0

Hi, I am new to Measurement Studio.

For development machine i will be installing MStudio,

but for the target machine (end user), just installing .Net will suffice?

 

Target Platforms (Win 7 and Win 10)

Too long runtime on AnalogMultiChannelReader.ReadMultiSample with NationalInstruments

$
0
0


When I use this method ReadMultiSample in ReadCcv and ReadOcv its take more then a second of run time.

I think its too long What can I do to make it run faster?

 

 

 

My controller class

class Controller
{
public AnalogMultiChannelReader reader;
public bool TaskIsRunning { get; set; }
public double Current_ { get; set; }
public double dTime_ { get; set; }
public Single Ocv_ { get; set; }
public Single Ccv_ { get; set; }
public long OcvtaskHandle { get; set; }
private MessageBasedSession mbSession;
Task CcvTask;
Task OcvTask;
~Controller()
{
CcvTask.Dispose();
OcvTask.Dispose();
}
public Controller() {
CcvTask = null;
OcvTask = null;
}

public double ReadCcv()
{
// Create a new task
double frequency = 50000;
double TimePerPoint = (1 / frequency);
int numSampsPerChannel = (int)((dTime_ / 1000.0) * frequency) + 95;

if (CcvTask == null)
{
InitLoad();
// Initialize Local Variables
double rangeMinimum = Convert.ToDouble(GlobalVariables.rangeMinVolt);
double rangeMaximum = Convert.ToDouble(GlobalVariables.rangeMaxVolt);

CcvTask = new Task();

CcvTask.AIChannels.CreateVoltageChannel(GlobalVariables.voltageSorceInput, "",
(AITerminalConfiguration)(-1), rangeMinimum, rangeMaximum, AIVoltageUnits.Volts);

CcvTask.Timing.ConfigureSampleClock("", frequency, SampleClockActiveEdge.Rising,
SampleQuantityMode.FiniteSamples, numSampsPerChannel);

CcvTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(GlobalVariables.triggerSorcePort, DigitalEdgeStartTriggerEdge.Rising);// ReferenceTrigger.ConfigureDigitalEdgeTrigger(

CcvTask.Control(TaskAction.Verify);
}
try
{
AnalogMultiChannelReader reader = new AnalogMultiChannelReader(CcvTask.Stream);

SendSCPI("PROG:STAT RUN");

double[,] x = reader.ReadMultiSample(numSampsPerChannel);

string res = "";

return x[0, numSampsPerChannel - 90];
}
catch (DaqException exception)
{
//startButton.Enabled = true;
//myTask.Dispose();
throw exception;
}
}

public bool GetFootSwitch(){

Task myTask = new NationalInstruments.DAQmx.Task();
myTask.DIChannels.CreateChannel(GlobalVariables.footSwitchPort, "FootSwitch",ChannelLineGrouping.OneChannelForEachLine);
DigitalSingleChannelReader reader = new DigitalSingleChannelReader(myTask.Stream);

bool val = reader.ReadSingleSampleMultiLine().First();
return val;

}

public void BeepOk(int Periode=600){
Task myTask = new Task();

myTask.DOChannels.CreateChannel(GlobalVariables.beepPort, "beep",ChannelLineGrouping.OneChannelForAllLines);
DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(myTask.Stream);
writer.WriteSingleSampleMultiLine(true, new bool[]{true});
Thread.Sleep(Periode);
writer.WriteSingleSampleMultiLine(true, new bool[]{false});

}


public double ReadOcv()
{
int numSampsPerChannel = 1000;
int numChannels = 1;
List<double> data = new List<double>();
double rangeMinimum = Convert.ToDouble(GlobalVariables.rangeMinVolt);
double rangeMaximum = Convert.ToDouble(GlobalVariables.rangeMaxVolt);
string x = "";
int arraySizeInSamps = numSampsPerChannel * numChannels;

if (OcvTask == null)
{
OcvTask = new Task();
OcvTask.AIChannels.CreateVoltageChannel(GlobalVariables.voltageSorceInput, "", (AITerminalConfiguration)(-1), rangeMinimum, rangeMaximum, AIVoltageUnits.Volts);
OcvTask.Timing.ConfigureSampleClock("", numSampsPerChannel, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, 101);
data = new List<double>(arraySizeInSamps - 1);
}
AnalogSingleChannelReader r = new AnalogSingleChannelReader(OcvTask.Stream);

data = r.ReadMultiSample(numSampsPerChannel).ToList();

return data.Average();
}

private void SendSCPI(string text)
{
mbSession.BeginWrite(text + "\n");
}

public void InitLoad()
{
ResourceManager rmSession = ResourceManager.GetLocalManager();
mbSession = (UsbSession)rmSession.Open("USB0::0x0B3E::0x1004::ND002613::0::INSTR", AccessModes.NoLock, 10000);
SendSCPI("PROG:FSP:END 10");
SendSCPI("PROG:FSP:TIME 0.0001");
SendSCPI("PROG:NAME 11");
for (int j = 1; j <= 10; j++)
{
Thread.Sleep(5);
SendSCPI("PROG:FSP:EDIT " + j + "," + (Current_/1000).ToString("#0.000") + ",1,1");
}

SendSCPI("PROG:LOOP" + dTime_);


}
// This routine reads the string returned by the instrument
private string GetSCPI()
{
string ret = mbSession.ReadString();
return ret.Replace("\n", "").Replace("\0", "");

}


public void initFluke(){
ResourceManager rmSession = ResourceManager.GetLocalManager();
mbSession = (SerialSession)rmSession.Open("asrl3::instr",AccessModes.NoLock,10000);

SendSCPI("PROG:FSP:END 10");

((SerialSession)mbSession).BaudRate = 115200;
((SerialSession)mbSession).FlowControl = 0;
((SerialSession)mbSession).Parity = 0;
}
}


My main class :

class Program
{
static Controller controller = new Controller();

static void testRun() {
double ocv = controller.ReadOcv();
double ccv = controller.ReadCcv();
}

static void Main(string[] args)
{
controller.dTime_ = 100;
controller.Current_ = 5000;

testRun();
testRun();
testRun();
testRun();
testRun();

Console.ReadLine();

}
}

Bessel Filter code for equiv: LabView "init/cont" for filter pre conditions.

$
0
0

Meas.Studio 10: looking for equiv code that's emulates the "init/cont" (T/F) setting in LabView for setting initial conditions or past filter condition for a Bessel Filter application.

WPF MeterDouble RangeFill binding in DataTemplate

$
0
0

I am loading meters dynamically with an items control panel and formatting the data and style via data template.  The binding for the meter value and range works fine. 

 

I want to highlight a range on the meter scale that works like the WinForms ScaleRangeFill.

 

I read for the WPF controls, this must be done with niSmiley Tonguerimitives.  I followed an example shown for a guage.

 

I can manually code the Baseloine RelativeOffset and RelativeLength values, but they will not bind to a property of the current object handled by the data template.  Below is my XAML.

 

I cannot dynamically bind the Green range shown in this screen shot.  I can only hard code the values in the XAML.

 

What am I missing?

 

 

 

 

 

<!-- ////////////////////////////////////////////////////////// -->

<!-- Motor Block Meter1                                         -->

<!-- ////////////////////////////////////////////////////////// -->

<!—This style is located in an external styling xaml file, the binding for range is OK -->

    <Style x:Key="MotorBlockMeterStyle" TargetType="{x:Type ni:MeterDouble}">

        <Setter Property="Height" Value="Auto" />

        <Setter Property="Width" Value="Auto" />

        <Setter Property="Margin" Value="1,1,1,1" />

        <Setter Property="Range" Value="{Binding Range, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />

    </Style>

 

 

 

 

User control:

<UserControl xmlns:ni="http://schemas.ni.com/controls/2009/xaml/presentation"

             xmlns:niPrimitives="http://schemas.ni.com/controls/2009/xaml/presentation/primitives"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

             xmlns:local="clr-namespace:Auma.EMP.TestBench.UserControls"

             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"        

             x:Class="Auma.EMP.TestBench.UserControls.MotorBlockMeterView"

             xmlns:Custom="http://www.galasoft.ch/mvvmlight"

             mc:Ignorable="d" >

 

    <UserControl.Resources>

 

        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>

                <ResourceDictionary Source="..\Styles\EMPTestBenchStyles.xaml"/>

            </ResourceDictionary.MergedDictionaries>

 

            <DataTemplate x:Key="MotorBlockMeterTemplate">

 

                <StackPanel>

                    <Label Content="{Binding Caption, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">

 

                    </Label>

                    <ni:MeterDouble

                    Value="{Binding Value, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"

                    Style="{DynamicResource MotorBlockMeterStyle}"

                    >

                        <ni:MeterDouble.TrackDecorations>

                            <niPrimitives:RelativeRadialScalePanel

                                niPrimitives:RelativeRadialHostPanel.Edge="Inside"

                                niPrimitives:RelativePanel.RelativeWidth="1.0"

                                niPrimitives:RelativePanel.RelativeHeight="1.0"

                                niPrimitives:RelativePanel.RelativeHorizontalPosition="0.5"

                                niPrimitives:RelativePanel.RelativeHorizontalAlignment="Center"

                                ArcSweep="{Binding ScaleArc, RelativeSource={RelativeSource AncestorType=ni:MeterDouble}}"

                                >

<!— This is the Binding of the RelativeOffset and RelativeLength will not work here! -->

<!— The binding to a property of the current item handled by the DataTemplate is not working -->

<!— I can manually code values here, such as “0.5” but I cannot get a value to bind -->

<!— Is the DataContext changing in the Baseline element, and if so, do how do I get it back to the DataTemplate object? -->

 

                                <niPrimitives:Baseline

                                    

                                    RelativeOffset="{Binding RangeFillOffset, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"

                                    RelativeLength="0.5"

                                   

                                    Stroke="#FF32CD32"

                                    StrokeThickness="40"

                                    StrokeEndLineCap="Flat"

                                    StrokeStartLineCap="Flat">

                                   

                                </niPrimitives:Baseline>

                            </niPrimitives:RelativeRadialScalePanel>

                        </ni:MeterDouble.TrackDecorations>

                    </ni:MeterDouble>

                </StackPanel>

 

            </DataTemplate>

 

 

        </ResourceDictionary>

    </UserControl.Resources>

 

 

    <StackPanel DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:MotorBlockMeterView}}">

 

        <Border

            Style="{DynamicResource SwitchControlBottomBorderStyle}">

            <Grid

            

            HorizontalAlignment="Stretch"

            Height="Auto"

            VerticalAlignment="Top"

            Width="Auto">

                <Grid.ColumnDefinitions>

                    <ColumnDefinition></ColumnDefinition>

                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>

                    <RowDefinition></RowDefinition>

                </Grid.RowDefinitions>

 

                <ItemsControl Grid.Column="0" Grid.Row="0"

                            ItemsSource="{Binding Path=DataContext.MBMVM.Meters, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"

                            ItemTemplate="{StaticResource MotorBlockMeterTemplate}"

                    >

                    <ItemsControl.ItemsPanel>

                        <ItemsPanelTemplate>

                            <StackPanel>

                            </StackPanel>

                        </ItemsPanelTemplate>

                    </ItemsControl.ItemsPanel>

                </ItemsControl>

            </Grid>

        </Border>

    </StackPanel>

</UserControl>

on the plot ,the CURSOR is moved automaticly left,this is the question:how can I fix the cursor at the position.

$
0
0

on the plot ,the CURSOR is  moved automaticly left,this is the question:how can I fix the cursor at the position. 

on the CWgraph,there is a option:snap to plot with fixed x,but at the current measurement studio,only the item:snap to plot,how can i fix the cursor at a position on the plot.

the cursor snaping to plot moves left automatically,in the C# program using measurement studio.

$
0
0

        when running the C# spectrum program,on the plot ,the CURSOR is  moved automatically left when the spectrum-graph waves.When the spectrum-graph doesn't wave,the cursor stop at the right fixed position .this is the question:how can I fix the cursor at the position when the spectrum-graph waves

        In the old version measurement studio,the  CWgraph has a option:snap to plot with fixed x,but at the current measurement studio,only the item:snap to plot,how can i fix the cursor at a position on the plot.

PCI-6515 change detection problem

$
0
0

Hello,

 

I use the example for measurement studion "ReadDigChan_ChangeDetection", If I add a simulation device of PCI-6515 in MAX, it works and when I start the program, I can ready the value of each line.  But when it works in a real PCI6515, it will not show any signal of the board and give me an error like timeout.

 

My question is. even the signal is not always changing as the simulation, but why it doesn't show the first time value? and when the first time value I can see,  how can I keep monitor the signal? Put the time out=-1? I tried it, looks the program no response.

if I run single reading, It works ok.

 

I don't want to use timer to read value.

 

I use visual studio 2010 and Measurement studio 2015, Max 2014.

 

Thanks in advance

 

 

 

private void startButton_Click(object sender, System.EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;

try
{
//Create a task such that it will be disposed after
//we are done using it.
myTask = new Task();

//Create channel
myTask.DIChannels.CreateChannel(physicalChannelComboBox.Text,"myChannel",
ChannelLineGrouping.OneChannelForAllLines);

myTask.Timing.ConfigureChangeDetection(
risingEdgeLinesComboBox.Text,
fallingEdgeLinesComboBox.Text,
SampleQuantityMode.ContinuousSamples, 1000);

myDigitalReader= new DigitalSingleChannelReader(myTask.Stream);

// Use SynchronizeCallbacks to specify that the object
// marshals callbacks across threads appropriately.
myDigitalReader.SynchronizeCallbacks = true;

runningTask = myTask;
myDigitalReader.BeginReadSingleSampleMultiLine(
new AsyncCallback(OnDataReady),
myTask);

startButton.Enabled = false;
stopButton.Enabled = true;
physicalChannelComboBox.Enabled = false;
risingEdgeLinesComboBox.Enabled = false;
fallingEdgeLinesComboBox.Enabled = false;
}
catch(DaqException exception)
{
MessageBox.Show(exception.Message);

//dispose task
if(myTask != null)
myTask.Dispose();
}
Cursor.Current = Cursors.Default;
}

private void OnDataReady(IAsyncResult result)
{
try
{
if (runningTask != null && runningTask == result.AsyncState)
{
bool[] data = myDigitalReader.EndReadSingleSampleMultiLine(result);
DisplayData(data);

myDigitalReader.BeginReadSingleSampleMultiLine(
new AsyncCallback(OnDataReady),
myTask);
}
}
catch(DaqException ex)
{
runningTask = null;
MessageBox.Show(ex.Message);
myDigitalReader = null;
myTask.Dispose();
startButton.Enabled = true;
stopButton.Enabled = false;
physicalChannelComboBox.Enabled = true;
risingEdgeLinesComboBox.Enabled = true;
fallingEdgeLinesComboBox.Enabled = true;
}
}


渥太华大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

渥太华大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

弗吉尼亚大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

弗吉尼亚大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

圣路易斯华盛顿大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

圣路易斯华盛顿大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

南卫理公会大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

南卫理公会大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

美国科罗拉多矿业大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

美国科罗拉多矿业大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

美国俄亥俄州立大学哥伦布分校毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

美国俄亥俄州立大学哥伦布分校毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

美国俄亥俄州立大学哥伦布分校毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

美国俄亥俄州立大学哥伦布分校毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证


美国耶斯希瓦大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

美国耶斯希瓦大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

美国圣地亚哥大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

美国圣地亚哥大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

佛罗里达州立大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

佛罗里达州立大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

密苏里大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

密苏里大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

路易斯安那州立大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

$
0
0

路易斯安那州立大学毕业,证@微信551.190476改成绩单GPA,买加拿大,澳洲,英国,美国大学毕业。证

Viewing all 1999 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>