Working Calibration EPD-N2
This commit is contained in:
parent
0d20d5e6a5
commit
a6a23510e9
7 changed files with 130 additions and 37 deletions
|
|
@ -150,6 +150,19 @@ WORD EpdBase::Epd2U::ReadStatus()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WORD EpdBase::Epd2U::EPDReadExtraStatus()
|
||||||
|
{
|
||||||
|
CommitRV = ReadA2ConfigStatus(
|
||||||
|
&byBatADC,
|
||||||
|
&bySupplyADC,
|
||||||
|
&byStatus3,
|
||||||
|
&byStatus4);
|
||||||
|
|
||||||
|
if (CommitRV == 1) CommitRV = Commit();
|
||||||
|
if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
|
||||||
|
return CommitRV;
|
||||||
|
}
|
||||||
|
|
||||||
WORD EpdBase::Epd2U::EPDReadConfig()
|
WORD EpdBase::Epd2U::EPDReadConfig()
|
||||||
{
|
{
|
||||||
ReadConfigRV = ReadConfig(
|
ReadConfigRV = ReadConfig(
|
||||||
|
|
@ -205,6 +218,21 @@ WORD EpdBase::Epd2U::TurnOn()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WORD EpdBase::Epd2U::WriteCal()
|
||||||
|
{
|
||||||
|
Password = 9;
|
||||||
|
//((BYTE *)&Password)[0] = 9;
|
||||||
|
|
||||||
|
CommitRV = MFRLogin(Password);
|
||||||
|
if (CommitRV == 1) CommitRV = Commit();
|
||||||
|
if (CommitRV == 1) CommitRV = MFRWriteCalFactors(K1, K2, K3, K4, K5, K6);
|
||||||
|
if (CommitRV == 1) CommitRV = Commit();
|
||||||
|
if (CommitRV == 0) Error = GetErrorDetails(&ErrorSource, &ErrorReason, &ErrorData);
|
||||||
|
return CommitRV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WORD EpdBase::Epd2U::ReadTresHolds()
|
WORD EpdBase::Epd2U::ReadTresHolds()
|
||||||
{
|
{
|
||||||
Hp10THDose1 = Hp10THDose2 = Hp07THDose = 0;
|
Hp10THDose1 = Hp10THDose2 = Hp07THDose = 0;
|
||||||
|
|
@ -329,7 +357,7 @@ WORD EpdBase::Epd2U::Issue()
|
||||||
if (OKRV) OKRV = Commit();
|
if (OKRV) OKRV = Commit();
|
||||||
if (OKRV) OKRV = IssueEpd(WearerID, WearerIDLength);
|
if (OKRV) OKRV = IssueEpd(WearerID, WearerIDLength);
|
||||||
if (OKRV) OKRV = Commit();
|
if (OKRV) OKRV = Commit();
|
||||||
if (OKRV) OKRV = WriteWearerName(WearerName,WearerNameLength);
|
if (OKRV) OKRV = WriteWearerName(WearerName,strlen((char *)WearerName));
|
||||||
if (OKRV) OKRV = Commit();
|
if (OKRV) OKRV = Commit();
|
||||||
if (OKRV) OKRV = ClearFailFlag(); // all actions have been completed
|
if (OKRV) OKRV = ClearFailFlag(); // all actions have been completed
|
||||||
if (OKRV) OKRV = Commit();
|
if (OKRV) OKRV = Commit();
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,15 @@ namespace EpdBase
|
||||||
BYTE OtherAlarmBatVolt = 0;
|
BYTE OtherAlarmBatVolt = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DWORD Password = 9;
|
||||||
|
|
||||||
|
|
||||||
|
BYTE byBatADC;
|
||||||
|
BYTE bySupplyADC;
|
||||||
|
BYTE byStatus3;
|
||||||
|
BYTE byStatus4;
|
||||||
|
|
||||||
void StartDiscover();
|
void StartDiscover();
|
||||||
void Open(DWORD DeviceID);
|
void Open(DWORD DeviceID);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
@ -187,9 +196,11 @@ namespace EpdBase
|
||||||
|
|
||||||
Epd2U(int comport);
|
Epd2U(int comport);
|
||||||
WORD ReadStatus();
|
WORD ReadStatus();
|
||||||
|
WORD EPDReadExtraStatus();
|
||||||
WORD EPDReadConfig();
|
WORD EPDReadConfig();
|
||||||
WORD TurnOff();
|
WORD TurnOff();
|
||||||
WORD TurnOn();
|
WORD TurnOn();
|
||||||
|
WORD WriteCal();
|
||||||
WORD ReadTresHolds();
|
WORD ReadTresHolds();
|
||||||
WORD ReadDoses();
|
WORD ReadDoses();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,14 +111,10 @@ int EpdBaseClr::Epd2::SetDeIssued()
|
||||||
|
|
||||||
int EpdBaseClr::Epd2::SetIssued()
|
int EpdBaseClr::Epd2::SetIssued()
|
||||||
{
|
{
|
||||||
epd->AlarmDoseHP07N = Hp07THDose;
|
|
||||||
epd->AlarmDoseHP101G = Hp10THDose1;
|
|
||||||
epd->AlarmDoseHP102G = Hp10THDose1;
|
|
||||||
|
|
||||||
|
epd->Hp07THDose = Hp07THDose*64;
|
||||||
epd->Hp07THDose = Hp07THDose;
|
epd->Hp10THDose1 = Hp10THDose1*64;
|
||||||
epd->Hp10THDose1 = Hp10THDose1;
|
epd->Hp10THDose2 = Hp10THDose2*64;
|
||||||
epd->Hp10THDose2 = Hp10THDose2;
|
|
||||||
|
|
||||||
epd->Hp10Rate1On = Hp10Rate1On;
|
epd->Hp10Rate1On = Hp10Rate1On;
|
||||||
epd->Hp10Rate2On = Hp10Rate2On;
|
epd->Hp10Rate2On = Hp10Rate2On;
|
||||||
|
|
@ -146,6 +142,16 @@ int EpdBaseClr::Epd2::SetIssued()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int EpdBaseClr::Epd2::WriteCalibration()
|
||||||
|
{
|
||||||
|
epd->K3 = K3;
|
||||||
|
epd->K4 = K4;
|
||||||
|
int rv= epd->WriteCal();
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int EpdBaseClr::Epd2::ReadTresholds()
|
int EpdBaseClr::Epd2::ReadTresholds()
|
||||||
{
|
{
|
||||||
epd->ReadTresHolds();
|
epd->ReadTresHolds();
|
||||||
|
|
@ -176,4 +182,13 @@ int EpdBaseClr::Epd2::ReadTresholds()
|
||||||
HG = epd->HG;
|
HG = epd->HG;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EpdBaseClr::Epd2::ReadExtraStatus()
|
||||||
|
{
|
||||||
|
int rv = epd->EPDReadExtraStatus();
|
||||||
|
BatADC = epd->byBatADC;
|
||||||
|
SupplyADC = epd->bySupplyADC;
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +82,9 @@ namespace EpdBaseClr {
|
||||||
int FunctionFlags ;
|
int FunctionFlags ;
|
||||||
|
|
||||||
|
|
||||||
|
unsigned short BatADC;
|
||||||
|
unsigned short SupplyADC;
|
||||||
|
|
||||||
Epd2(int port);
|
Epd2(int port);
|
||||||
~Epd2();
|
~Epd2();
|
||||||
!Epd2();
|
!Epd2();
|
||||||
|
|
@ -98,8 +101,12 @@ namespace EpdBaseClr {
|
||||||
|
|
||||||
int SetIssued();
|
int SetIssued();
|
||||||
|
|
||||||
|
int WriteCalibration();
|
||||||
|
|
||||||
int ReadTresholds();
|
int ReadTresholds();
|
||||||
|
|
||||||
|
int ReadExtraStatus();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@ namespace eDosStation
|
||||||
this.Close();
|
this.Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
statusEPD.Text = $"EPD: {ep.b.CurrentDeviceID}";
|
||||||
|
ep.ReadTresholds();
|
||||||
|
|
||||||
//ep.Hp07THDose =
|
//ep.Hp07THDose =
|
||||||
}
|
}
|
||||||
|
|
@ -68,8 +69,7 @@ namespace eDosStation
|
||||||
if (ep.DiscRV == 1 && ep.b.CurrentDeviceID > 0)
|
if (ep.DiscRV == 1 && ep.b.CurrentDeviceID > 0)
|
||||||
{
|
{
|
||||||
EpdFound = true;
|
EpdFound = true;
|
||||||
statusEPD.Text = $"EPD: {ep.b.CurrentDeviceID}";
|
DoEPD();
|
||||||
LoadDoses();
|
|
||||||
}
|
}
|
||||||
if (!EpdFound)
|
if (!EpdFound)
|
||||||
{
|
{
|
||||||
|
|
@ -89,27 +89,10 @@ namespace eDosStation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void GetEPD()
|
private void DoEPD()
|
||||||
{
|
{
|
||||||
if (_User == null || CurTaskRow == null) return;
|
LoadDoses();
|
||||||
|
|
||||||
ep = new EpdBaseClr.Epd2(Properties.Settings.Default.comport);
|
|
||||||
ep.Connect();
|
|
||||||
if (ep.DiscRV == 1 && ep.b.CurrentDeviceID > 0)
|
|
||||||
{
|
|
||||||
EpdFound = true;
|
|
||||||
statusEPD.Text= $"EPD: {ep.b.CurrentDeviceID}";
|
|
||||||
LoadDoses();
|
|
||||||
}
|
|
||||||
if (!EpdFound)
|
|
||||||
{
|
|
||||||
statusEPD.Text= $"EPD: Wait ";
|
|
||||||
Search = 100;
|
|
||||||
dispatcherTimer = new DispatcherTimer();
|
|
||||||
dispatcherTimer.Tick += DispatcherTimer_Tick;
|
|
||||||
dispatcherTimer.Interval = new TimeSpan(0, 0, 2);
|
|
||||||
dispatcherTimer.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isBG = (ep.epdType == 3);
|
bool isBG = (ep.epdType == 3);
|
||||||
int? VisitID = null;
|
int? VisitID = null;
|
||||||
|
|
@ -126,7 +109,7 @@ namespace eDosStation
|
||||||
pa = new SqlParameter("ID_Visit", SqlDbType.Int, 4); pa.Direction = ParameterDirection.Output; cmd1.Parameters.Add(pa);
|
pa = new SqlParameter("ID_Visit", SqlDbType.Int, 4); pa.Direction = ParameterDirection.Output; cmd1.Parameters.Add(pa);
|
||||||
co.Open();
|
co.Open();
|
||||||
cmd1.ExecuteNonQuery();
|
cmd1.ExecuteNonQuery();
|
||||||
VisitID = (int ?)cmd1.Parameters["ID_Visit"].Value;
|
VisitID = (int?)cmd1.Parameters["ID_Visit"].Value;
|
||||||
co.Close();
|
co.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +127,41 @@ namespace eDosStation
|
||||||
ep.Hp10THDose2 = CurTaskRow.Hp10Dose2;
|
ep.Hp10THDose2 = CurTaskRow.Hp10Dose2;
|
||||||
ep.Hp07THDose = CurTaskRow.Hp07Dose;
|
ep.Hp07THDose = CurTaskRow.Hp07Dose;
|
||||||
|
|
||||||
|
int kx = (int)CurTaskRow.FNGain_ANGainValue;
|
||||||
|
if (ep.K3 != kx || ep.K4 != kx)
|
||||||
|
{
|
||||||
|
ep.K3 = ep.K4 = kx;
|
||||||
|
ep.WriteCalibration();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ep.SetIssued();
|
ep.SetIssued();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetEPD()
|
||||||
|
{
|
||||||
|
if (_User == null || CurTaskRow == null) return;
|
||||||
|
|
||||||
|
ep = new EpdBaseClr.Epd2(Properties.Settings.Default.comport);
|
||||||
|
ep.Connect();
|
||||||
|
if (ep.DiscRV == 1 && ep.b.CurrentDeviceID > 0)
|
||||||
|
{
|
||||||
|
EpdFound = true;
|
||||||
|
|
||||||
|
DoEPD();
|
||||||
|
}
|
||||||
|
if (!EpdFound)
|
||||||
|
{
|
||||||
|
statusEPD.Text= $"EPD: Wait ";
|
||||||
|
Search = 100;
|
||||||
|
dispatcherTimer = new DispatcherTimer();
|
||||||
|
dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||||
|
dispatcherTimer.Interval = new TimeSpan(0, 0, 2);
|
||||||
|
dispatcherTimer.Start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,17 @@
|
||||||
</StatusBar>
|
</StatusBar>
|
||||||
<Grid TextBlock.FontSize="24" TextBlock.FontFamily="Comic Sans MS">
|
<Grid TextBlock.FontSize="24" TextBlock.FontFamily="Comic Sans MS">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="auto" />
|
||||||
|
<RowDefinition Height="auto" />
|
||||||
<RowDefinition Height="auto" />
|
<RowDefinition Height="auto" />
|
||||||
<RowDefinition Height="auto" />
|
<RowDefinition Height="auto" />
|
||||||
<RowDefinition Height="auto" />
|
<RowDefinition Height="auto" />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition />
|
<ColumnDefinition Width="auto" />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition Width="auto" />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition Width="auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -29,7 +31,7 @@
|
||||||
<TextBlock Grid.Row="0" Grid.Column="2" Name ="EpdVisit" Text=""/>
|
<TextBlock Grid.Row="0" Grid.Column="2" Name ="EpdVisit" Text=""/>
|
||||||
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Dose" Margin="5,10,0,0" />
|
<TextBlock Grid.Row="1" Grid.Column="0" Text="Dose" Margin="5,10,0,0" />
|
||||||
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical" Margin="5,10,0,0">
|
<StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Orientation="Vertical" Margin="5,10,0,0">
|
||||||
<TextBlock Name="HpDose07" />
|
<TextBlock Name="HpDose07" />
|
||||||
<TextBlock Name="HpDose10" />
|
<TextBlock Name="HpDose10" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
@ -40,6 +42,13 @@
|
||||||
<TextBlock Name="HP10AlarmDose1" />
|
<TextBlock Name="HP10AlarmDose1" />
|
||||||
<TextBlock Name="HP10AlarmDose2" />
|
<TextBlock Name="HP10AlarmDose2" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="3" Grid.Column="0" Text="Battery" Grid.RowSpan="2" VerticalAlignment="Center" />
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="3" Grid.Column="1" Name="BatVolt" />
|
||||||
|
<TextBlock Grid.Row="4" Grid.Column="1" Name="SupplyVolt" />
|
||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,13 @@ namespace eDosStation
|
||||||
ep.ReadTresholds();
|
ep.ReadTresholds();
|
||||||
HP10AlarmDose1.Text = $"Alarm HP10(1) {ep.Hp10THDose1:0.00} µSv";
|
HP10AlarmDose1.Text = $"Alarm HP10(1) {ep.Hp10THDose1:0.00} µSv";
|
||||||
HP10AlarmDose2.Text = $"Alarm HP10(2) {ep.Hp10THDose2:0.00} µSv";
|
HP10AlarmDose2.Text = $"Alarm HP10(2) {ep.Hp10THDose2:0.00} µSv";
|
||||||
HP07AlarmDose.Text = $"Alarm HP07 {ep.Hp07THDose:0.00} µSv";
|
HP07AlarmDose.Text = $"Alarm HP07 {ep.Hp07THDose:0.00} µSv";
|
||||||
|
|
||||||
|
ep.ReadExtraStatus();
|
||||||
|
|
||||||
|
BatVolt.Text = $" {ep.BatADC * 16.0} mV";
|
||||||
|
SupplyVolt.Text = $" {ep.SupplyADC* 16.0} mV";
|
||||||
|
|
||||||
//int Hp10THDose2;
|
//int Hp10THDose2;
|
||||||
//int Hp07THDose;
|
//int Hp07THDose;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue