• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Create service-application for windows XP

Hi,

If using a service isn't a wise thing to do, than other solutions are welcome too. I need to build it from scratch anyway.

The following is what I want to accomplish:
A customer is visiting my trainingfacility. He is checking-in by using his magnet-card.
The magnetcardreader is attached to a serial-com port.

Here is the part the service comes in:
The service-application identified that data is send by the com-port.
The send data contains an identificationnumber of the customer.
The service will update a database to register that the customer is present. (if he scans a second time he will be checked-out).
Also the service will show a windows-popup containing the name and picture of the customer.
The popupscreen will disapear automatically after 3 seconds.

What would be a good way to implement this behaviour?
Can anybody give me some example or guidelines?

Regards,
Stef
0
Stef Merlijn
Asked:
Stef Merlijn
  • 3
  • 3
1 Solution
 
2266180Commented:
a service is a good idea and fits the needs.

now the needed imlementation is the trocky part: you don't know/have anything on how to do it?
1) do you have components for the serial communication part?
2) do you have the database part covered or are you able to cover it?
3) is the popup thing really needed? better make that configurable (imagine the case of 10-30 customers visiting at once (not a real life situation, but you never know)

it's been a while since I last worked with serial communication, but at that time (about 33-4 years ago) I used AsyncFree.
as database components, it really depends on the backend.

the implementation itself is pretty simple though:
- the service will start a listener thread that gets the data from the serial port. when data is available, it is put in a queue and a callback function of somekind is called that get the data from the queue (synchronization is needed here ;) )and makes out the data package in a readable format for the app. this is then put in the DB and the popup (which runs in its own thread)  is fired.

that should be it.
0
 
Stef MerlijnDeveloperAuthor Commented:
Thank you for your info.
I don't have any experience with using threads, listening to serialports nor callback (synchronisation) and queing of data. I can cover the databasepart, so we can skip that.
I don't have any component for the serial communication part, but will buy probably TMS ASync32.

So as you see a lot of help is needed here.
0
 
2266180Commented:
well then, we'll do it one step at a time:
1) get familiar with TMS ASync 32 (this should be fairly easy, so you can actually write a class that gets the desired data from the card reader)
2) for threads, you can look over the following examples/tutorials: http://delphi.about.com/od/kbthread/
3) queueing data basically implies to use a queue class (TQueue, TObjectQueue for example: add "contnrs" to the uses clause to use them; use push/pop to add get items from the queue)
4) synchronizing access to a resource can be done in various ways: semaphores, critical sections, mutex, etc. I couldn't find a good tutorial on this for delphi, but the following is pretty good for a begginer: http://www.sci.csuhayward.edu/~billard/cs4560/node7.html
 Probably the easiest way for a begginer is to use a thread-safe component. I couldn't find in a short period of time a good example for this.
Personally I prefer using critical sections to do the job. You have more control over things with this :)

uses SyncObjs;
global var cs:TCriticalSection = new TCriticalSection;// one per shared resource

....
  try
    cs.Enter;
    try
      use the resource
    finally
      cs.Leave;
    end;
  except
  end;
---

the above pattern will make sure that no critical section will be left locked ;)

let me know when you bump into issues
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Stef MerlijnDeveloperAuthor Commented:
At the moment I can't do any testing as I have to wait for my own customer to give a GO to the project. So I don't have ASync32 nor a magnetreader.
The way you describe the way to implement it is not that easily form me to understand as I have no experience with this part of delphi-programming. So some additional help would be greatly appreciated when the project will start.
0
 
2266180Commented:
well, we answer questions here, solve problems, but we do not help in making projects. there are other sites  (services) for that were you can hire a coder to do part or all of the job.
we can give you pointers, examples and otherwise information that will help you do your job, but not do your job or part of it for you. it's not ethical.

the information I have given you in basic design and some examples/tutorials are more than enough to get your on the right tracks. but you have to do the rest yourself and come back when you have problems/issues implementing and we will help you gladly.

cheers
0
 
Stef MerlijnDeveloperAuthor Commented:
I understand that.
Thank you for your directions.

Regards,
Stef
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now