2.35 Elatec

This commit is contained in:
Luc Vandenbroucke 2024-10-14 13:31:46 +02:00
parent b642ec89af
commit 44b24f0d4b
8 changed files with 124 additions and 30 deletions

View file

@ -45,6 +45,7 @@
<add key="ClientSettingsProvider.ServiceUri" value="" /> <add key="ClientSettingsProvider.ServiceUri" value="" />
<add key="LogAll" value="true" /> <add key="LogAll" value="true" />
<add key="WriteConfig" value="true" /> <add key="WriteConfig" value="true" />
<add key="Elatec" value="COM5" />
</appSettings> </appSettings>
<system.web> <system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider"> <membership defaultProvider="ClientAuthenticationMembershipProvider">

View file

@ -37,6 +37,7 @@ namespace eDosStation
private DateTime ResultTime; private DateTime ResultTime;
private bool EpdReading=false; private bool EpdReading=false;
private bool FinalTimeOut=false; private bool FinalTimeOut=false;
enum eCOE { quiz = 1 }; enum eCOE { quiz = 1 };
#if SimulateEPD #if SimulateEPD
@ -644,7 +645,7 @@ namespace eDosStation
} }
EpdReading = false; EpdReading = false;
dispatcherTimer?.Stop(); dispatcherTimer?.Stop();
dispatcherTimer = null; dispatcherTimer = null;
this.Close(); this.Close();
} }
@ -953,29 +954,54 @@ namespace eDosStation
} }
//StartBadge //StartBadge
if (dfReader == null) if (thisStation.isElatec)
{ {
dfReader = new LSWDesfirePublic.CCard(); thisStation.ReceivedPersid = Pelatec_DataReceived;
dfReader.GetReaderList(); } else
if (dfReader.readersList.Contains(thisStation.Reader)) {
if (dfReader == null)
{ {
dfReader.SetReader(thisStation.Reader); dfReader = new LSWDesfirePublic.CCard();
dfReader.Badged += DFReader_Badged;
dfReader.BadgeTO += DfReader_BadgeTO;
dfReader.BadgeError += DfReader_BadgeError;
ReaderTask = dfReader.Wait(PageTimeout,10);
}
else
{
StringBuilder er = new StringBuilder($"Badgelezer \"{thisStation.Reader}\" niet gevonden!.\nDeze lezers zijn beschikbaar:\n");
dfReader.GetReaderList(); dfReader.GetReaderList();
foreach (string r in dfReader.readersList) er.AppendLine($"-> {r}"); if (dfReader.readersList.Contains(thisStation.Reader))
MessageBox.Show(er.ToString(), "Badge Lezer", MessageBoxButton.OK, MessageBoxImage.Exclamation); {
dfReader.Dispose(); dfReader = null; dfReader.SetReader(thisStation.Reader);
dfReader.Badged += DFReader_Badged;
dfReader.BadgeTO += DfReader_BadgeTO;
dfReader.BadgeError += DfReader_BadgeError;
ReaderTask = dfReader.Wait(PageTimeout, 10);
}
else
{
StringBuilder er = new StringBuilder($"Badgelezer \"{thisStation.Reader}\" niet gevonden!.\nDeze lezers zijn beschikbaar:\n");
dfReader.GetReaderList();
foreach (string r in dfReader.readersList) er.AppendLine($"-> {r}");
MessageBox.Show(er.ToString(), "Badge Lezer", MessageBoxButton.OK, MessageBoxImage.Exclamation);
dfReader.Dispose(); dfReader = null;
}
} }
} }
} }
private void Pelatec_DataReceived(int PersID)
{
this.Dispatcher.InvokeAsync(new Action(() => showBadge(PersID, null)), DispatcherPriority.Background);
}
//private void Pelatec_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
//{
// var v = elatecReader.ReadLine();
// int PersID;
// if (!int.TryParse(v, out PersID)) PersID = 0;
// if (PersID > 0)
// this.Dispatcher.InvokeAsync(new Action(() => showBadge(PersID, null)), DispatcherPriority.Background);
// else
// {
// string msg = $"No PersID found on badge ";
// MessageBox.Show(msg, "Error", MessageBoxButton.OK);
// thisStation.splunkLog?.WriteSplunkLog("Badged", LSWLib.CLog.iseverity.warning, null, msg);
// }
//}
private void DfReader_BadgeError(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeErrorEventArgs e) private void DfReader_BadgeError(LSWDesfirePublic.CCard Sender, LSWDesfirePublic.BadgeErrorEventArgs e)
{ {
endPage(); endPage();

View file

@ -10,6 +10,7 @@ namespace eDosStation
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
const string className = "MainWindow"; const string className = "MainWindow";
public DataInterface dataInterface; public DataInterface dataInterface;
public Station thisStation; public Station thisStation;

View file

@ -63,5 +63,6 @@ using System.Windows;
//2.31 extra disconnect/connect //2.31 extra disconnect/connect
//2.32 VS2022 //2.32 VS2022
//2.34 close com at end , also MK2 //2.34 close com at end , also MK2
[assembly: AssemblyVersion("2.34.0.0")] //2.35 Elatec
[assembly: AssemblyFileVersion("2.34.0.0")] [assembly: AssemblyVersion("2.35.0.0")]
[assembly: AssemblyFileVersion("2.35.0.0")]

View file

@ -1 +1 @@
Mon 10/14/2024 9:54:23.70 Mon 10/14/2024 13:29:05.87

View file

@ -26,6 +26,7 @@
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="20" /> <RowDefinition Height="20" />
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -74,11 +75,13 @@
<TextBlock Grid.Row="13" Grid.Column="0" Text="Write config 3.2" Height="23" Margin="0,0,0.2,0" VerticalAlignment="Top"></TextBlock> <TextBlock Grid.Row="13" Grid.Column="0" Text="Write config 3.2" Height="23" Margin="0,0,0.2,0" VerticalAlignment="Top"></TextBlock>
<CheckBox Grid.Row="13" Grid.ColumnSpan="2" Name="cbWriteConfig32" Grid.Column="1" Padding="10,0,10,0" VerticalAlignment="Center" /> <CheckBox Grid.Row="13" Grid.ColumnSpan="2" Name="cbWriteConfig32" Grid.Column="1" Padding="10,0,10,0" VerticalAlignment="Center" />
<TextBlock Grid.Row="14" Grid.Column="0" Text="Log all" Height="23" Margin="0,0,0.2,0" VerticalAlignment="Top"></TextBlock> <TextBlock Grid.Row="14" Grid.Column="0" Text="Log all" VerticalAlignment="Top"></TextBlock>
<CheckBox Grid.Row="14" Grid.ColumnSpan="2" Name="cbLogAll" Grid.Column="1" Padding="10,0,10,0" VerticalAlignment="Center" /> <CheckBox Grid.Row="14" Grid.ColumnSpan="2" Name="cbLogAll" Grid.Column="1" Padding="10,0,10,0" VerticalAlignment="Center" />
<TextBlock Grid.Row="15" Grid.Column="0" Text="Elatec Com port"></TextBlock>
<telerik:RadComboBox Grid.Row="15" Grid.ColumnSpan="2" Name="eComPort" Grid.Column="1" />
<telerik:RadButton Grid.Row="16" Grid.Column="0" Name="bOK" Content="OK" Click="BOK_Click" Style="{DynamicResource OkCancelButton}" /> <telerik:RadButton Grid.Row="17" Grid.Column="0" Name="bOK" Content="OK" Click="BOK_Click" Style="{DynamicResource OkCancelButton}" />
<telerik:RadButton Grid.Row="16" Grid.Column="1" Name="bCancel" Content="Cancel" Click="BCancel_Click" Style="{DynamicResource OkCancelButton}" HorizontalAlignment="Right" /> <telerik:RadButton Grid.Row="17" Grid.Column="1" Name="bCancel" Content="Cancel" Click="BCancel_Click" Style="{DynamicResource OkCancelButton}" HorizontalAlignment="Right" />
</Grid> </Grid>
</Window> </Window>

View file

@ -121,6 +121,8 @@ namespace eDosStation
thisStation.LogAll = cbLogAll.IsChecked != null ? cbLogAll.IsChecked.Value : false; thisStation.LogAll = cbLogAll.IsChecked != null ? cbLogAll.IsChecked.Value : false;
thisStation.ElatecPort = eComPort.SelectedValue.ToString().Trim();
step = "Update"; step = "Update";
thisStation.Update(); thisStation.Update();
@ -129,7 +131,6 @@ namespace eDosStation
thisStation?.splunkLog?.WriteSplunkLog(module, LSWLib.CLog.iseverity.err, thisStation.ErrorMessage); thisStation?.splunkLog?.WriteSplunkLog(module, LSWLib.CLog.iseverity.err, thisStation.ErrorMessage);
MessageBox.Show($"Error {thisStation.ErrorMessage}"); MessageBox.Show($"Error {thisStation.ErrorMessage}");
} }
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
@ -185,6 +186,7 @@ namespace eDosStation
foreach (string cn in System.IO.Ports.SerialPort.GetPortNames()) foreach (string cn in System.IO.Ports.SerialPort.GetPortNames())
{ {
cComPort.Items.Add(cn); cComPort.Items.Add(cn);
eComPort.Items.Add(cn);
} }
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info); thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
} }
@ -258,6 +260,19 @@ namespace eDosStation
thisStation?.splunkLog?.WriteException(className, step, ex); thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"Serial err {ex.Message}"); MessageBox.Show($"Serial err {ex.Message}");
} }
step = "Select ecom";
try
{
string thisComport = thisStation.ElatecPort;
if (!eComPort.Items.Contains(thisComport)) eComPort.Items.Add(thisComport);
eComPort.SelectedItem = thisComport;
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
}
catch (System.Exception ex)
{
thisStation?.splunkLog?.WriteException(className, step, ex);
MessageBox.Show($"Serial err {ex.Message}");
}
step = "tbInstallations"; step = "tbInstallations";
try try

View file

@ -1,9 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Diagnostics.Eventing.Reader;
using System.Text; using System.Text;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Threading;
using static eDosStation.Station;
using spl1 = LSWLib.CLog; using spl1 = LSWLib.CLog;
namespace eDosStation namespace eDosStation
{ {
@ -22,6 +26,8 @@ namespace eDosStation
public string TestCSN { get; set; } public string TestCSN { get; set; }
public string TestCode { get; set; } public string TestCode { get; set; }
public string Reader { get; internal set; } public string Reader { get; internal set; }
public bool isElatec { get; internal set; }
public string ElatecPort { get; internal set; }
public bool useTestButtons { get; set; } public bool useTestButtons { get; set; }
public byte useBeep { get; set; } public byte useBeep { get; set; }
public bool checkUser { get; internal set; } public bool checkUser { get; internal set; }
@ -41,6 +47,7 @@ namespace eDosStation
public double InfoScreenTimeout { get; internal set; } public double InfoScreenTimeout { get; internal set; }
public bool WriteConfig32 { get; internal set; } public bool WriteConfig32 { get; internal set; }
System.IO.Ports.SerialPort elatecReader;
public string sComPort { get { return MakeComportString(ComPort); } } public string sComPort { get { return MakeComportString(ComPort); } }
public const int defInst_CODE1 = 1; public const int defInst_CODE1 = 1;
@ -59,6 +66,10 @@ namespace eDosStation
internal bool LogAll; internal bool LogAll;
internal bool WriteConfig; internal bool WriteConfig;
public delegate void dReceivedPersID(int persid);
public dReceivedPersID ReceivedPersid;
public ushort useBeepMK3() public ushort useBeepMK3()
{ {
if (beepMk3Map.ContainsKey(useBeep)) if (beepMk3Map.ContainsKey(useBeep))
@ -68,6 +79,7 @@ namespace eDosStation
public Station(DataInterface mDataInterface, string Station) public Station(DataInterface mDataInterface, string Station)
{ {
const string taskName = "StationInit"; const string taskName = "StationInit";
ReceivedPersid = null;
splunkLog = new spl1(Environment.MachineName); splunkLog = new spl1(Environment.MachineName);
stationLog = null; stationLog = null;
dataInterface = mDataInterface; dataInterface = mDataInterface;
@ -84,6 +96,14 @@ namespace eDosStation
LogAll = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["LogAll"]); LogAll = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["LogAll"]);
else else
LogAll = false; LogAll = false;
if (System.Configuration.ConfigurationManager.AppSettings["Elatec"] != null) {
ElatecPort = System.Configuration.ConfigurationManager.AppSettings["Elatec"];
if (!string.IsNullOrWhiteSpace(ElatecPort)) isElatec = true;
} else
isElatec = false;
if (System.Configuration.ConfigurationManager.AppSettings["WriteConfig"] != null) if (System.Configuration.ConfigurationManager.AppSettings["WriteConfig"] != null)
WriteConfig = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["WriteConfig"]); WriteConfig = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["WriteConfig"]);
else else
@ -129,7 +149,8 @@ namespace eDosStation
Inst_Name1 = rs.StringOrDefault("Inst_Name1", string.Empty); Inst_Name1 = rs.StringOrDefault("Inst_Name1", string.Empty);
Inst_Name2 = rs.StringOrDefault("Inst_Name2", string.Empty); Inst_Name2 = rs.StringOrDefault("Inst_Name2", string.Empty);
TestCSN = rs.StringOrDefault("TestCSN", string.Empty); TestCSN = rs.StringOrDefault("TestCSN", string.Empty);
Reader = rs.StringOrDefault("Reader", string.Empty);
if (!isElatec) Reader = rs.StringOrDefault("Reader", string.Empty); else Reader = string.Empty;
useTestButtons = rs.BoolOrDefault("useTestButtons", false); useTestButtons = rs.BoolOrDefault("useTestButtons", false);
useBeep = rs.ByteOrDefault("useBeep", 0b00010110); useBeep = rs.ByteOrDefault("useBeep", 0b00010110);
doLog = rs.BoolOrDefault("doLog", false); doLog = rs.BoolOrDefault("doLog", false);
@ -152,7 +173,7 @@ namespace eDosStation
TestCSN = System.Configuration.ConfigurationManager.AppSettings["TestCSN"]; TestCSN = System.Configuration.ConfigurationManager.AppSettings["TestCSN"];
TestCode = System.Configuration.ConfigurationManager.AppSettings["TestCode"]; TestCode = System.Configuration.ConfigurationManager.AppSettings["TestCode"];
Changed = true; Changed = true;
Reader = System.Configuration.ConfigurationManager.AppSettings["Reader"]; if (!isElatec) Reader = System.Configuration.ConfigurationManager.AppSettings["Reader"]; else Reader = string.Empty;
checkUser = false; checkUser = false;
EPDTimeOut = 10000; EPDTimeOut = 10000;
EPDRetries = 2; EPDRetries = 2;
@ -212,7 +233,10 @@ namespace eDosStation
} }
co?.Close(); co?.Close();
} }
DevCon = new cDevCon(ComPort, splunkLog); DevCon = new cDevCon(ComPort, splunkLog);
if (isElatec) openElatec();
} }
private void CmdSetParams(SqlCommand cmd) private void CmdSetParams(SqlCommand cmd)
{ {
@ -274,10 +298,11 @@ namespace eDosStation
public void UpdateAppSettings() public void UpdateAppSettings()
{ {
string[] Keys = { "LogAll" } ; string[] Keys = { "LogAll", "Elatec" } ;
string[] Values = { "false" }; string[] Values = { "false" ,"" };
Values[0] = LogAll.ToString(); Values[0] = LogAll.ToString();
Values[1] = ElatecPort;
try try
{ {
var configFile = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); var configFile = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
@ -358,6 +383,28 @@ namespace eDosStation
if (!string.IsNullOrEmpty(er)) splunkLog?.WriteSplunkLog(module, spl1.iseverity.err, er); if (!string.IsNullOrEmpty(er)) splunkLog?.WriteSplunkLog(module, spl1.iseverity.err, er);
return er; return er;
} }
public void openElatec()
{
if (isElatec)
{
elatecReader = new System.IO.Ports.SerialPort(ElatecPort, 115200);
elatecReader.DataReceived += ElatecReader_DataReceived;
elatecReader.Open();
}
}
private void ElatecReader_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
if (ReceivedPersid != null)
{
var v = elatecReader.ReadLine();
int PersID;
if (!int.TryParse(v, out PersID)) PersID = 0;
ReceivedPersid(PersID);
}
}
} }
} }