Skip to content
Permalink
Browse files

working changes 11/09

  • Loading branch information...
teodor-krastev committed Sep 11, 2017
1 parent c3e353c commit b20c8157f0073a8417f1d552375a1ff12d9ebd34
@@ -67,10 +67,7 @@
<Reference Include="NationalInstruments.Controls.Booleans, Version=15.0.45.3898, Culture=neutral, PublicKeyToken=4febd62461bf11a4, processorArchitecture=MSIL" />
<Reference Include="NationalInstruments.Controls.Graphs, Version=15.0.45.3898, Culture=neutral, PublicKeyToken=4febd62461bf11a4, processorArchitecture=MSIL" />
<Reference Include="NationalInstruments.Controls.Numerics, Version=15.0.45.3898, Culture=neutral, PublicKeyToken=4febd62461bf11a4, processorArchitecture=MSIL" />
<Reference Include="NationalInstruments.DAQmx, Version=16.1.45.70, Culture=neutral, PublicKeyToken=4febd62461bf11a4, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\NationalInstruments.DAQmx.dll</HintPath>
</Reference>
<Reference Include="NationalInstruments.DAQmx, Version=15.5.45.109, Culture=neutral, PublicKeyToken=4febd62461bf11a4, processorArchitecture=x86" />
<Reference Include="NationalInstruments.Net, Version=15.0.45.49153, Culture=neutral, PublicKeyToken=4febd62461bf11a4, processorArchitecture=x86">
<Private>False</Private>
</Reference>
@@ -42,17 +42,58 @@
<TabItem x:Name="tabSignal" Header="Signal" Width="100" Height="28">
<Grid Margin="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="391*"/>
<ColumnDefinition Width="391*"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<ListBox x:Name="lboxNB" Grid.Column="1" Margin="0" Grid.ColumnSpan="1" FontSize="13">
<Grid Grid.Column="0" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="26"/>
<RowDefinition Height="70*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<CheckBox x:Name="chkN1" Content="N1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0" IsChecked="True" Checked="chkN1_Checked" Unchecked="chkN1_Checked"/>
<CheckBox x:Name="chkN2" Content="N2" VerticalAlignment="Center" Margin="5,0,0,0" IsChecked="True" Unchecked="chkN1_Checked" Checked="chkN1_Checked"/>
<CheckBox x:Name="chkNtot" Content="Ntot" VerticalAlignment="Center" Margin="5,0,0,0" IsChecked="True" Unchecked="chkN1_Checked" Checked="chkN1_Checked"/>
<Label x:Name="lbInfo1" Content="Info:" Margin="8,0,0,0" VerticalAlignment="Center" Height="31" FontSize="13" HorizontalAlignment="Left" Width="173"/>
</StackPanel>
<ni:Graph x:Name="graphNs" Grid.Row="1" Margin="0,0,0,0" FontSize="12" PlotAreaMargin="Auto,Auto,Auto,Auto" >
<ni:Graph.Plots>
<ni:Plot x:Name="plotN1" Label="N1">
<ni:PlotRendererGroup>
<ni:LinePlotRenderer Stroke="Green"/>
<ni:PointPlotRenderer Fill="Green" Size="3,3"/>
</ni:PlotRendererGroup>
</ni:Plot>
<ni:Plot x:Name="plotNtot" Label="Ntot">
<ni:PlotRendererGroup>
<ni:LinePlotRenderer Stroke="#FF800600"/>
<ni:PointPlotRenderer Fill="#FF800C00" Stroke="#FF8A0404" Size="3,3"/>
</ni:PlotRendererGroup>
</ni:Plot>
<ni:Plot x:Name="plotN2" Label="Ntot">
<ni:PlotRendererGroup>
<ni:LinePlotRenderer Stroke="#FF061BCA"/>
<ni:PointPlotRenderer Fill="#FF0762C6" Stroke="#FF0A51BD" Size="3,3"/>
</ni:PlotRendererGroup>
</ni:Plot>
</ni:Graph.Plots>
<ni:Graph.SelectionFill>
<SolidColorBrush Color="#FFF8EFC2" Opacity="0.3"/>
</ni:Graph.SelectionFill>
</ni:Graph>
</Grid>

<ListBox x:Name="lboxNB" Grid.Column="2" Margin="0" Grid.ColumnSpan="1" FontSize="13">
<ListBoxItem Content="N2"/>
<ListBoxItem Content="NTot"/>
<ListBoxItem Content="B2"/>
<ListBoxItem Content="BTot"/>
<ListBoxItem Content="Bg"/>
</ListBox>
<Grid Grid.Column="0" Margin="0">
<GridSplitter x:Name="splitSignal" HorizontalAlignment="Left" Grid.Column="1" Margin="0,0,0,0" Background="#FFEFFDFA" ResizeDirection="Columns" Width="4"/>

<Grid Grid.Column="1" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="26"/>
<RowDefinition Height="70*"/>
@@ -70,8 +111,8 @@
<SolidColorBrush Color="#FFF8EFC2" Opacity="0.3"/>
</ni:Graph.SelectionFill>
</ni:Graph>
<ni:GraphInteractionPalette Grid.Row="0" x:Name="interatctionOverview" HorizontalAlignment="Stretch" Height="23" VerticalAlignment="Top" ButtonSize="22,22" Graph="{Binding ElementName=graphSignal}" Margin="10,4,565,0"/>
<Label x:Name="lbInfo" Content="Info:" HorizontalAlignment="Left" Margin="216,0,0,0" Grid.RowSpan="2" VerticalAlignment="Top" Height="31" Width="560" FontSize="13"/>
<ni:GraphInteractionPalette Grid.Row="0" x:Name="interatctionOverview" HorizontalAlignment="Stretch" Height="23" VerticalAlignment="Top" ButtonSize="22,22" Graph="{Binding ElementName=graphSignal}" Margin="10,4,189,0" Grid.RowSpan="2"/>
<Label x:Name="lbInfo" Content="Info:" Margin="216,0,0,0" VerticalAlignment="Center" Height="31" FontSize="13" HorizontalAlignment="Left" Width="173"/>
</Grid>
</Grid>
</TabItem>
@@ -205,7 +246,7 @@
<GroupBox x:Name="groupStatFringes" Header=" Statistics " Margin="0" Grid.Column="2" FontSize="12">
<Grid Margin="0">
<Label Content="REM:" HorizontalAlignment="Left" Margin="9,8,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.529,0.182"/>
<TextBox x:Name="tbRemFringes" HorizontalAlignment="Left" Height="23" Margin="51,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="529"/>
<TextBox x:Name="tbRemFringes" HorizontalAlignment="Left" Height="23" Margin="51,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="394"/>
</Grid>
</GroupBox>
<GroupBox Header="Jumbo Scan params" Margin="0,0,5.143,0">
@@ -216,8 +257,6 @@
<ni:NumericTextBoxDouble x:Name="numTo" HorizontalAlignment="Left" Height="23" Margin="57,44,0,0" VerticalAlignment="Top" Width="67" Value="12.56"/>
<Label Content="By" HorizontalAlignment="Left" Margin="10,68,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.601,3.165"/>
<ni:NumericTextBoxDouble x:Name="numBy" HorizontalAlignment="Left" Height="23" Margin="57,74,0,0" VerticalAlignment="Top" Width="67" Value="0.1"/>
<Label Content="Scan Parameter" HorizontalAlignment="Left" Margin="10,102,0,0" VerticalAlignment="Top" Width="111"/>
<ComboBox HorizontalAlignment="Left" Margin="14,136,0,0" VerticalAlignment="Top" Width="110"/>
</Grid>
</GroupBox>

@@ -237,8 +276,8 @@
<CheckBox x:Name="chkFollowPID" Content="Follow" HorizontalAlignment="Left" Margin="10,106,0,0" VerticalAlignment="Top" IsChecked="True" RenderTransformOrigin="0.5,0.5"/>
<GroupBox Header="Strobes" HorizontalAlignment="Left" Margin="0,126,0,0" VerticalAlignment="Top" Height="67" Width="103">
<StackPanel Margin="0,0,0.429,-12.714">
<RadioButton x:Name="rbSingle" Content="Single(down)" Margin="0,5,0,0" IsChecked="True" Checked="rbSingle_Checked"/>
<RadioButton x:Name="rbDouble" Content="Double" Margin="0,6,0,0" Checked="rbSingle_Checked"/>
<RadioButton x:Name="rbSingle" Content="Single(down)" Margin="0,5,0,0" IsChecked="True" />
<RadioButton x:Name="rbDouble" Content="Double" Margin="0,6,0,0" />
</StackPanel>
</GroupBox>
</Grid>
@@ -49,14 +49,17 @@ namespace Axel_hub
/// </summary>
public partial class MainWindow: Window
{
bool jumboScanFlag = true;
bool jumboScanFlag = false;
bool jumboRepeatFlag = true;
bool jumboADC24Flag = false;
bool jumboADC24Flag = true;

scanClass ucScan1;
int nSamples = 1500;
private AxelMems axelMems = null;
Random rnd = new Random();
DataStack stackN1 = new DataStack(true);
DataStack stackN2 = new DataStack(true);
DataStack stackNtot = new DataStack(true);
private List<Point> _fringePoints = new List<Point>();
public MainWindow()
{
@@ -69,6 +72,7 @@ public MainWindow()
ucScan1.Start += new scanClass.StartHandler(DoStart);
ucScan1.Remote += new scanClass.RemoteHandler(DoRemote);
ucScan1.FileRef += new scanClass.FileRefHandler(DoRefFile);
AxelChart1.Waveform.TimeSeriesMode = false;

axelMems = new AxelMems();
axelMems.Acquire += new AxelMems.AcquireHandler(DoAcquire);
@@ -89,6 +93,7 @@ private void log(string txt, Color? clr = null)
rangeOfText1.Text = printOut + "\n";
rangeOfText1.ApplyPropertyValue(TextElement.ForegroundProperty, new System.Windows.Media.SolidColorBrush(ForeColor));
tbLog.ScrollToEnd();

}

public void DoEvents()
@@ -116,7 +121,7 @@ private MMscan jumboScan()
return mms;
}

private void ADC24(bool down, double period, bool TimeMode, double Limit)
private void ADC24(bool down, double period, bool TimeLimitMode, double Limit)
{
if (!down) // user cancel
{
@@ -127,8 +132,8 @@ private void ADC24(bool down, double period, bool TimeMode, double Limit)
return;
}

AxelChart1.Waveform.TimeMode = TimeMode;
if (TimeMode)
AxelChart1.Waveform.TimeLimitMode = TimeLimitMode;
if (TimeLimitMode)
{
AxelChart1.Waveform.TimeLimit = Limit;
nSamples = (int)(Limit / period);
@@ -165,55 +170,10 @@ public void DoStart(bool jumbo, bool down, double period, bool TimeMode, double
lastGrpExe = new MMexec();
lastGrpExe.mmexec = "test_drive";
lastGrpExe.sender = "Axel-hub";
<<<<<<< HEAD

tabLowPlots.SelectedIndex = 0;
lastGrpExe.cmd = "scan";
lastGrpExe.id = rnd.Next(int.MaxValue);
lastScan = jumboScan();
lastScan.ToDictionary(ref lastGrpExe.prms);

string json = JsonConvert.SerializeObject(lastGrpExe);
log("<< "+json, Brushes.Green.Color);
ucScan1.remoteMode = RemoteMode.Jumbo_Scan;
ucScan1.SendJson(json);
//TODO Check scan mode works correctly with MM
return;

if (ucScan1.remoteMode == RemoteMode.Free) return; // abort mission
tabLowPlots.SelectedIndex = 1;
lastGrpExe.cmd = "repeat";
lastGrpExe.id = rnd.Next(int.MaxValue);
lastGrpExe.prms.Clear();
lastGrpExe.prms["groupID"] = DateTime.Now.ToString("yy-MM-dd_H-mm-ss");
lastGrpExe.prms["cycles"] = 100;
json = JsonConvert.SerializeObject(lastGrpExe);
log("<< " + json, Brushes.Blue.Color);

ucScan1.remoteMode = RemoteMode.Jumbo_Repeat;
ucScan1.SendJson(json);

if(ucScan1.remoteMode != RemoteMode.Free) ucScan1.bbtnStart_Click(null, null); // reset
ucScan1.remoteMode = RemoteMode.Free;
}
else
{
if (!down) // user cancel
{
AxelChart1.Running = false;
axelMems.StopAqcuisition();
AxelChart1.Waveform.logger.Enabled = false;
return;
}
Random random = new Random();

AxelChart1.Waveform.TimeMode = TimeMode;
if (TimeMode)
=======


if(jumboScanFlag)
>>>>>>> dfd61a3629f960f08c14fac684cab30ae3959d71
{
Clear();
tabLowPlots.SelectedIndex = 0;
lastGrpExe.cmd = "scan";
lastGrpExe.id = rnd.Next(int.MaxValue);
@@ -228,12 +188,13 @@ >>>>>>> dfd61a3629f960f08c14fac684cab30ae3959d71
}
if(jumboRepeatFlag)
{
Clear();
tabLowPlots.SelectedIndex = 1;
lastGrpExe.cmd = "repeat";
lastGrpExe.id = rnd.Next(int.MaxValue);
lastGrpExe.prms.Clear();
lastGrpExe.prms["groupID"] = DateTime.Now.ToString("yy-MM-dd_H-mm-ss");
lastGrpExe.prms["cycles"] = 100;
lastGrpExe.prms["cycles"] = -1;
if (rbSingle.IsChecked.Value) lastGrpExe.prms["strobes"] = 1;
else lastGrpExe.prms["strobes"] = 2;

@@ -245,10 +206,12 @@ >>>>>>> dfd61a3629f960f08c14fac684cab30ae3959d71
}
if(jumboADC24Flag) ADC24(down, 0.001, false, 200);

ucScan1.Abort(false); // reset
log("Jumbo succession is RUNNING !", Brushes.Green.Color);
//ucScan1.Abort(false); // reset
}
else
{
Clear(true, false, false);
ADC24(down, period, TimeMode, Limit);
}
}
@@ -337,6 +300,9 @@ public void DoAcquire(List<Point> dt, out bool next)
signalDataStack.Add(new Point(xVal, yVal));
xVal++;
}
stackN1.AddPoint(NTot - N2); stackN2.AddPoint(N2); stackNtot.AddPoint(NTot);
graphNs.Data[0] = stackN1; graphNs.Data[1] = stackN2; graphNs.Data[2] = stackNtot;

xVal = 0; double B2 = ((double[])mme.prms["B2"]).Average();
foreach (double yVal in (double[])mme.prms["B2"])
{
@@ -349,10 +315,8 @@ public void DoAcquire(List<Point> dt, out bool next)
backgroundDataStack.Add(new Point(xVal, yVal));
xVal++;
}
Point[] pA, pB;
pA = signalDataStack.ToArray();
pB = backgroundDataStack.ToArray();
graphSignal.DataSource = new List<Point[]>() {pA, pB};
graphSignal.Data[0] = signalDataStack;
graphSignal.Data[1] = backgroundDataStack;
double A = 1 - 2 * (N2 - B2) / (NTot - BTot), corr, debalance;
if (lastGrpExe.cmd.Equals("scan")) // title command
{
@@ -399,6 +363,7 @@ public void DoAcquire(List<Point> dt, out bool next)
lastGrpExe = mme.Clone();
if (!mme.sender.Equals("Axel-hub")) ucScan1.remoteMode = RemoteMode.Simple_Repeat;
tabLowPlots.SelectedIndex = 1;
Clear();
}
break;
case ("scan"):
@@ -413,6 +378,7 @@ public void DoAcquire(List<Point> dt, out bool next)
lastGrpExe = mme.Clone();
if (!mme.sender.Equals("Axel-hub")) ucScan1.remoteMode = RemoteMode.Simple_Scan;
tabLowPlots.SelectedIndex = 0;
chkN1_Checked(null, null);
}
break;
case ("abort"):
@@ -568,21 +534,39 @@ private void ndKP_KeyDown(object sender, KeyEventArgs e)
}
}

private void rbSingle_Checked(object sender, RoutedEventArgs e)
private void Clear(bool Top = true, bool Middle = true, bool Low = true)
{
/* if ((crsFringes2 == null) || (crsFringes1 == null)) return;
if (rbSingle.IsChecked.Value)
if (Top) AxelChart1.Clear();
if (Middle)
{
crsFringes2.Visibility = System.Windows.Visibility.Hidden;
crsFringes1.AxisValue = 7.85;
stackN1.Clear(); stackN2.Clear(); stackNtot.Clear();
lboxNB.Items.Clear();
}
else
if (Low)
{
crsFringes2.Visibility = System.Windows.Visibility.Visible;
crsFringes1.AxisValue = 4.71;
crsFringes1.AxisValue = 7.85;
leftLvl = double.NaN; rightLvl = double.NaN;
}*/
if (!Utils.isNull(srsFringes)) srsFringes.Clear();
if (!Utils.isNull(srsMotAccel)) srsMotAccel.Clear();
if (!Utils.isNull(srsCorr)) srsCorr.Clear();
}
}

private void chkN1_Checked(object sender, RoutedEventArgs e)
{
if (plotN1 != null)
{
if (chkN1.IsChecked.Value) plotN1.Visibility = System.Windows.Visibility.Visible;
else plotN1.Visibility = System.Windows.Visibility.Hidden;
}
if (plotN2 != null)
{
if (chkN2.IsChecked.Value) plotN2.Visibility = System.Windows.Visibility.Visible;
else plotN2.Visibility = System.Windows.Visibility.Hidden;
}
if (plotNtot != null)
{
if (chkNtot.IsChecked.Value) plotNtot.Visibility = System.Windows.Visibility.Visible;
else plotNtot.Visibility = System.Windows.Visibility.Hidden;
}
}
}
}

0 comments on commit b20c815

Please sign in to comment.
You can’t perform that action at this time.