Skip to content
Snippets Groups Projects
Commit 15089843 authored by developer3's avatar developer3
Browse files

Ubacivanje testera za multi DLL.

U pitanju je DLL za uFCoder v3.4.1 koji u sebi ima i funkcije za single i funkcije za multi uFR rad.

Funkcije za multi imaju handle i u nazivu je postfix M.


Ovaj primer je prevashodno pravljen za "kuću strave"

git-svn-id: svn://192.168.1.162/sw_open/ufr/c%23/examples/trunk@26 ca34c7d2-1fbc-e241-8d02-f02e9b27dd3e
parent 3834818c
Branches
No related merge requests found
Showing
with 1200 additions and 0 deletions

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uFR_multiDLL_tester", "uFR_multiDLL_tester\uFR_multiDLL_tester.csproj", "{8195D82F-B382-46AB-83C5-4EB73FCC086B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8195D82F-B382-46AB-83C5-4EB73FCC086B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8195D82F-B382-46AB-83C5-4EB73FCC086B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8195D82F-B382-46AB-83C5-4EB73FCC086B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8195D82F-B382-46AB-83C5-4EB73FCC086B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
File added
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace uFR_multiDLL_tester
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMultiuFRTester());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("uFR_multiDLL_tester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("uFR_multiDLL_tester")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("550bef9b-7e0f-4025-aa9c-296372e9ffa4")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace uFR_multiDLL_tester.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("uFR_multiDLL_tester.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace uFR_multiDLL_tester.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
File added
File added
File added
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
File added
File added
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
File added
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using uFCoderMulti; // DL_STATUS
namespace uFR_multiDLL_tester
{
using UFR_HANDLE = System.UIntPtr;
public partial class frmMultiuFRTester : Form
{
int block = 0;
List<uFReader> readers_list = new List<uFReader>();
DL_STATUS status;
string msg;
public frmMultiuFRTester()
{
InitializeComponent();
SetupDataGridView();
//eSector.SelectedIndex = 0;
//eBlockSec.SelectedIndex = 0;
}
private void error_wr(string pre_text, DL_STATUS status)
{
string out_text = pre_text + ": ";
out_text += status;
// out_text += Environment.NewLine;
memoDebug.AppendText(out_text);
memoDebug.Update();
}
private void prndbg(string message)
{
string tmp;
tmp = Environment.NewLine;
tmp += "================================================";
tmp += Environment.NewLine;
tmp += message;
tmp += Environment.NewLine;
memoDebug.AppendText(tmp);
memoDebug.Update();
}
private void update_block()
{
int sector;
int blocksec;
try
{
sector = Convert.ToInt32(eSector.Text);
blocksec = Convert.ToInt32(eBlockSec.Text);
}
catch
{
sector = 0;
blocksec = 0;
}
block = sector * 4 + blocksec;
eBlock.Text = Convert.ToString(block);
}
// ==========================================================
private void SetupDataGridView()
{
gridReader.ColumnCount = 6;
gridReader.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy;
gridReader.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
gridReader.ColumnHeadersDefaultCellStyle.Font =
new Font(gridReader.Font, FontStyle.Bold);
gridReader.AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
gridReader.ColumnHeadersBorderStyle =
DataGridViewHeaderBorderStyle.Single;
gridReader.CellBorderStyle = DataGridViewCellBorderStyle.Single;
gridReader.GridColor = Color.Black;
gridReader.RowHeadersVisible = false;
gridReader.Columns[0].Name = "Index";
gridReader.Columns[1].Name = "Reader SN";
gridReader.Columns[2].Name = "Reader Type";
gridReader.Columns[3].Name = "FTDI Serial";
gridReader.Columns[4].Name = "FTDI Description";
gridReader.Columns[5].Name = "Opened";
//gridReader.Columns[4].DefaultCellStyle.Font =
// new Font(gridReader.DefaultCellStyle.Font, FontStyle.Italic);
gridReader.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
gridReader.MultiSelect = false;
//gridReader.Dock = DockStyle.Fill;
//gridReader.CellFormatting += new
// DataGridViewCellFormattingEventHandler(
// gridReader_CellFormatting);
}
//===========================================================
private void readers_get_count()
{
int NumberOfDevices;
foreach (uFReader reader in readers_list)
{
if (reader.opened) // Will match once
{
reader.close();
msg = "Closed reader: " + reader.get_designator();
prndbg(msg);
}
}
readers_list.Clear();
gridReader.Rows.Clear();
gridReader.Update();
msg = "( All opened readers are closed now ! )" + Environment.NewLine;
msg += "Checking... Create new list... please wait...";
prndbg(msg);
NumberOfDevices = uFReader.get_reader_count();
msg = "Device found: " + NumberOfDevices.ToString();
prndbg(msg);
for (int i = 0; i < NumberOfDevices; i++)
{
uFReader ufr = new uFReader(i);
readers_list.Add(ufr);
gridReader.Rows.Add(ufr.get_info());
gridReader.Update();
}
}
private void readers_get_info()
{
if (0 == readers_list.Count)
{
msg = "No D-LOGIC uFReader device connected !" + Environment.NewLine;
msg += "( connect uFR device(s) and use click Get Count )";
prndbg(msg);
return;
}
// check all connected readers
// for descrition, types, serials
gridReader.Rows.Clear();
foreach (uFReader ufr in readers_list)
{
gridReader.Rows.Add(ufr.get_info());
}
}
private void reader_open(int idx)
{
if (readers_list.Count == 0)
return;
uFReader ufr = readers_list[idx];
status = ufr.open();
error_wr("ReaderList_OpenByIndex()", status);
if (DL_STATUS.UFR_OK == status)
{
msg = ufr + "connected.";
}
else
{
msg = ufr + "NOT connected !";
}
prndbg(msg);
gridReader.Rows[idx].SetValues(ufr.get_info());
gridReader.Update();
}
private void reader_close(int idx)
{
if (readers_list.Count == 0)
return;
uFReader ufr = readers_list[idx];
status = ufr.close();
if (status == DL_STATUS.UFR_OK)
{
msg = ufr + ": closed.";
}
else
{
msg = ufr + ": NOT closed ! >>> " + status;
}
prndbg(msg);
gridReader.Rows[idx].SetValues(ufr.get_info());
gridReader.Update();
}
//------------------------------------------------------
private void data_rd()
{
if (readers_list.Count == 0)
return;
uFReader ufr = readers_list[gridReader.CurrentRow.Index];
byte[] data = new byte[16];
int block_nr = Convert.ToInt32(eBlock.Text);
eData.Text = "";
status = ufr.read(block_nr, data);
msg = ufr + "read";
error_wr(msg, status);
if (status != DL_STATUS.UFR_OK)
return;
msg = "Data: ";
msg += BitConverter.ToString(data);
prndbg(msg);
eData.Text = System.Text.Encoding.UTF8.GetString(data);
}
private void data_wr()
{
if (readers_list.Count == 0)
return;
uFReader ufr = readers_list[gridReader.CurrentRow.Index];
byte[] data = new byte[16];
int block_nr = Convert.ToInt32(eBlock.Text);
byte[] data1 = System.Text.Encoding.ASCII.GetBytes(eData.Text);
int data_size = eData.Text.Length;
if (data_size > data.Length)
data_size = data.Length;
Array.Copy(data1, data, data_size);
status = ufr.write(block_nr, data);
msg = ufr + "write";
error_wr(msg, status);
}
//===========================================================
private void bGetCount_Click(object sender, EventArgs e)
{
readers_get_count();
}
private void bGetInfo_Click(object sender, EventArgs e)
{
readers_get_info();
}
private void bOpenByIdx_Click(object sender, EventArgs e)
{
reader_open(gridReader.CurrentRow.Index);
}
private void bCloseByIdx_Click(object sender, EventArgs e)
{
reader_close(gridReader.CurrentRow.Index);
}
//===========================================================
private void bOpenAll_Click(object sender, EventArgs e)
{
readers_get_count();
if (readers_list.Count == 0)
return;
foreach (uFReader ufr in readers_list)
{
reader_open(ufr.list_idx);
}
bOpenAll.Enabled = false;
bCloseAll.Enabled = true;
}
private void bCloseAll_Click(object sender, EventArgs e)
{
foreach (uFReader ufr in readers_list)
{
reader_close(ufr.list_idx);
}
bOpenAll.Enabled = true;
bCloseAll.Enabled = false;
}
//-----------------------------------------------------------
private void eSector_SelectedIndexChanged(object sender, EventArgs e)
{
update_block();
}
private void eBlockSec_SelectedIndexChanged(object sender, EventArgs e)
{
update_block();
}
//-----------------------------------------------------------
private void cbPollReaders_CheckedChanged(object sender, EventArgs e)
{
timerPoll.Enabled = cbPollReaders.Checked;
cbPollReaders.BackColor = cbPollReaders.Checked ? Color.Lime : SystemColors.Control;
}
private void timerPoll_Tick(object sender, EventArgs e)
{
if (!cbPollReaders.Checked)
return;
bool detected = false;
DL_STATUS status;
string asDate;
string asFTDI;
string str;
// only info with card will show
CARD_SAK Sak = CARD_SAK.UNKNOWN;
byte[] baUid = new byte[7];
foreach (uFReader ufr in readers_list)
{
if (!ufr.opened)
continue;
status = ufr.GetCardIdEx(ref Sak, ref baUid);
if (status != DL_STATUS.UFR_OK)
continue;
// CARD OK
asDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
asFTDI = ufr.ftdi_sn;
str = asDate + " | [" + asFTDI + "] | ";
// return hex.Replace("-", "");
str += BitConverter.ToString(baUid);
str += " (" + baUid.Length + ") | ";
str += Sak;
str += Environment.NewLine;
memoDetected.AppendText(str);
memoDetected.Update();
detected = true;
}
if (detected)
// try
memoDetected.SaveFile(eFileNameDetectedCard.Text);
}
private void gridReader_SelectionChanged(object sender, EventArgs e)
{
eReader.Text = gridReader.CurrentRow.Index.ToString();
}
private void btWriteData_Click(object sender, EventArgs e)
{
data_wr();
}
private void btReadData_Click(object sender, EventArgs e)
{
data_rd();
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment