2.35 Elatec
This commit is contained in:
parent
b642ec89af
commit
44b24f0d4b
8 changed files with 124 additions and 30 deletions
|
|
@ -45,6 +45,7 @@
|
|||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
<add key="LogAll" value="true" />
|
||||
<add key="WriteConfig" value="true" />
|
||||
<add key="Elatec" value="COM5" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ namespace eDosStation
|
|||
private DateTime ResultTime;
|
||||
private bool EpdReading=false;
|
||||
private bool FinalTimeOut=false;
|
||||
|
||||
|
||||
enum eCOE { quiz = 1 };
|
||||
#if SimulateEPD
|
||||
|
|
@ -644,7 +645,7 @@ namespace eDosStation
|
|||
}
|
||||
EpdReading = false;
|
||||
dispatcherTimer?.Stop();
|
||||
|
||||
|
||||
dispatcherTimer = null;
|
||||
this.Close();
|
||||
}
|
||||
|
|
@ -953,29 +954,54 @@ namespace eDosStation
|
|||
}
|
||||
|
||||
//StartBadge
|
||||
if (dfReader == null)
|
||||
if (thisStation.isElatec)
|
||||
{
|
||||
dfReader = new LSWDesfirePublic.CCard();
|
||||
dfReader.GetReaderList();
|
||||
if (dfReader.readersList.Contains(thisStation.Reader))
|
||||
thisStation.ReceivedPersid = Pelatec_DataReceived;
|
||||
} else
|
||||
{
|
||||
if (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 = new LSWDesfirePublic.CCard();
|
||||
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;
|
||||
if (dfReader.readersList.Contains(thisStation.Reader))
|
||||
{
|
||||
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)
|
||||
{
|
||||
endPage();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace eDosStation
|
|||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
|
||||
const string className = "MainWindow";
|
||||
public DataInterface dataInterface;
|
||||
public Station thisStation;
|
||||
|
|
|
|||
|
|
@ -63,5 +63,6 @@ using System.Windows;
|
|||
//2.31 extra disconnect/connect
|
||||
//2.32 VS2022
|
||||
//2.34 close com at end , also MK2
|
||||
[assembly: AssemblyVersion("2.34.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.34.0.0")]
|
||||
//2.35 Elatec
|
||||
[assembly: AssemblyVersion("2.35.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.35.0.0")]
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Mon 10/14/2024 9:54:23.70
|
||||
Mon 10/14/2024 13:29:05.87
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="auto" />
|
||||
</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>
|
||||
<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" />
|
||||
|
||||
<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="16" Grid.Column="1" Name="bCancel" Content="Cancel" Click="BCancel_Click" Style="{DynamicResource OkCancelButton}" HorizontalAlignment="Right" />
|
||||
<telerik:RadButton Grid.Row="17" Grid.Column="0" Name="bOK" Content="OK" Click="BOK_Click" Style="{DynamicResource OkCancelButton}" />
|
||||
<telerik:RadButton Grid.Row="17" Grid.Column="1" Name="bCancel" Content="Cancel" Click="BCancel_Click" Style="{DynamicResource OkCancelButton}" HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ namespace eDosStation
|
|||
|
||||
thisStation.LogAll = cbLogAll.IsChecked != null ? cbLogAll.IsChecked.Value : false;
|
||||
|
||||
thisStation.ElatecPort = eComPort.SelectedValue.ToString().Trim();
|
||||
|
||||
step = "Update";
|
||||
thisStation.Update();
|
||||
|
||||
|
|
@ -129,7 +131,6 @@ namespace eDosStation
|
|||
thisStation?.splunkLog?.WriteSplunkLog(module, LSWLib.CLog.iseverity.err, thisStation.ErrorMessage);
|
||||
MessageBox.Show($"Error {thisStation.ErrorMessage}");
|
||||
}
|
||||
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
|
|
@ -185,6 +186,7 @@ namespace eDosStation
|
|||
foreach (string cn in System.IO.Ports.SerialPort.GetPortNames())
|
||||
{
|
||||
cComPort.Items.Add(cn);
|
||||
eComPort.Items.Add(cn);
|
||||
}
|
||||
thisStation.splunkLog?.WriteSplunkLog(step, LSWLib.CLog.iseverity.info);
|
||||
}
|
||||
|
|
@ -258,6 +260,19 @@ namespace eDosStation
|
|||
thisStation?.splunkLog?.WriteException(className, step, ex);
|
||||
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";
|
||||
try
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Threading;
|
||||
using static eDosStation.Station;
|
||||
using spl1 = LSWLib.CLog;
|
||||
namespace eDosStation
|
||||
{
|
||||
|
|
@ -22,6 +26,8 @@ namespace eDosStation
|
|||
public string TestCSN { get; set; }
|
||||
public string TestCode { get; 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 byte useBeep { get; set; }
|
||||
public bool checkUser { get; internal set; }
|
||||
|
|
@ -41,6 +47,7 @@ namespace eDosStation
|
|||
public double InfoScreenTimeout { get; internal set; }
|
||||
public bool WriteConfig32 { get; internal set; }
|
||||
|
||||
System.IO.Ports.SerialPort elatecReader;
|
||||
public string sComPort { get { return MakeComportString(ComPort); } }
|
||||
|
||||
public const int defInst_CODE1 = 1;
|
||||
|
|
@ -59,6 +66,10 @@ namespace eDosStation
|
|||
internal bool LogAll;
|
||||
internal bool WriteConfig;
|
||||
|
||||
public delegate void dReceivedPersID(int persid);
|
||||
|
||||
public dReceivedPersID ReceivedPersid;
|
||||
|
||||
public ushort useBeepMK3()
|
||||
{
|
||||
if (beepMk3Map.ContainsKey(useBeep))
|
||||
|
|
@ -68,6 +79,7 @@ namespace eDosStation
|
|||
public Station(DataInterface mDataInterface, string Station)
|
||||
{
|
||||
const string taskName = "StationInit";
|
||||
ReceivedPersid = null;
|
||||
splunkLog = new spl1(Environment.MachineName);
|
||||
stationLog = null;
|
||||
dataInterface = mDataInterface;
|
||||
|
|
@ -84,6 +96,14 @@ namespace eDosStation
|
|||
LogAll = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["LogAll"]);
|
||||
else
|
||||
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)
|
||||
WriteConfig = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["WriteConfig"]);
|
||||
else
|
||||
|
|
@ -129,7 +149,8 @@ namespace eDosStation
|
|||
Inst_Name1 = rs.StringOrDefault("Inst_Name1", string.Empty);
|
||||
Inst_Name2 = rs.StringOrDefault("Inst_Name2", 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);
|
||||
useBeep = rs.ByteOrDefault("useBeep", 0b00010110);
|
||||
doLog = rs.BoolOrDefault("doLog", false);
|
||||
|
|
@ -152,7 +173,7 @@ namespace eDosStation
|
|||
TestCSN = System.Configuration.ConfigurationManager.AppSettings["TestCSN"];
|
||||
TestCode = System.Configuration.ConfigurationManager.AppSettings["TestCode"];
|
||||
Changed = true;
|
||||
Reader = System.Configuration.ConfigurationManager.AppSettings["Reader"];
|
||||
if (!isElatec) Reader = System.Configuration.ConfigurationManager.AppSettings["Reader"]; else Reader = string.Empty;
|
||||
checkUser = false;
|
||||
EPDTimeOut = 10000;
|
||||
EPDRetries = 2;
|
||||
|
|
@ -212,7 +233,10 @@ namespace eDosStation
|
|||
}
|
||||
co?.Close();
|
||||
}
|
||||
|
||||
|
||||
DevCon = new cDevCon(ComPort, splunkLog);
|
||||
if (isElatec) openElatec();
|
||||
}
|
||||
private void CmdSetParams(SqlCommand cmd)
|
||||
{
|
||||
|
|
@ -274,10 +298,11 @@ namespace eDosStation
|
|||
|
||||
public void UpdateAppSettings()
|
||||
{
|
||||
string[] Keys = { "LogAll" } ;
|
||||
string[] Values = { "false" };
|
||||
string[] Keys = { "LogAll", "Elatec" } ;
|
||||
string[] Values = { "false" ,"" };
|
||||
|
||||
Values[0] = LogAll.ToString();
|
||||
Values[1] = ElatecPort;
|
||||
try
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue