For Programmers: Free Programming Magazines  


Home > Archive > Clipper > January 2007 > Keeping clocks synchronized









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Keeping clocks synchronized
diogenes

2007-01-06, 6:55 pm

Is there a way, within Clipper programs or outside of Clipper programs,
to keep clocks synchronized on a bunch of in-house locally networked
machines?

Here is my case in more detail:
-- I have a Clipper app that runs on multiple machines all at once, in
a local in-house network.
-- They all record lots of data to DBF files with date and time fields.
-- So it's important that the clocks on all the machines be set to the
same date and at least approximately the same time.
-- Sometimes, for whatever reason, one machine or another will get it's
clock set wrong.
-- This tends to make a mess of things.

I would like for each machine to re-set its own clock to agree with the
clock on the file server machine. This might be done in the app itself
each time the app is started on each machine. Or it might be done
outside the app, perhaps automatically each time the machine is booted,
or maybe from some kind of script or batch file each time the app is
started.

I have one big constraint: I don't have the source code to the app,
nor a Clipper compiler either. However, the app itself has a script
interpreter, and I can write a script that the app will run. If there
is a function to get the date/time from the server's clock, AND if
there is also a function to set the date/time on the local machine, AND
if those functions happen to be linked into the app already, then I can
use them. Otherwise, I will have to do it outside the app somehow.

If I have to write my own program, I probably can, using either C or
C++ or Visual Basic. I can also run a VBScript from a script in the
app.

The app uses the FiveWin library, but I only have the most sketchy
documentation of that. I know it has a lot of functions for doing
Winders API kinds of things, but I don't know much detail. I have no
good way to know what functions are already linked into the app, except
if I know the name of a particular function of interest, I can try it
and see if it works.

Suggestions, anyone?

-- Jay
---------------------------------------

Fred Zuckerman

2007-01-06, 6:55 pm

A couple of thoughts:

1. When the app starts, have it display the date/time to the user and ask
for their confirmation of correctness. If not, then immediately close the
app with a message.

2. When the app starts, have it look at the previously recorded data and
confirm that the current date/time is greater than all existing entries. If
not, then immediately close the app with a message.

3. When the app begins to record data, it could check the existing records
to find the last entry made and confirm that this entry is greater.

Good Luck,
Fred Zuckerman


"diogenes" <jjaeckel@gmail.com> wrote in message
news:1167332493.137180.189760@h40g2000cwb.googlegroups.com...
> Is there a way, within Clipper programs or outside of Clipper programs,
> to keep clocks synchronized on a bunch of in-house locally networked
> machines?
>
> Here is my case in more detail:
> -- I have a Clipper app that runs on multiple machines all at once, in
> a local in-house network.
> -- They all record lots of data to DBF files with date and time fields.
> -- So it's important that the clocks on all the machines be set to the
> same date and at least approximately the same time.
> -- Sometimes, for whatever reason, one machine or another will get it's
> clock set wrong.
> -- This tends to make a mess of things.
>
> I would like for each machine to re-set its own clock to agree with the
> clock on the file server machine. This might be done in the app itself
> each time the app is started on each machine. Or it might be done
> outside the app, perhaps automatically each time the machine is booted,
> or maybe from some kind of script or batch file each time the app is
> started.
>
> I have one big constraint: I don't have the source code to the app,
> nor a Clipper compiler either. However, the app itself has a script
> interpreter, and I can write a script that the app will run. If there
> is a function to get the date/time from the server's clock, AND if
> there is also a function to set the date/time on the local machine, AND
> if those functions happen to be linked into the app already, then I can
> use them. Otherwise, I will have to do it outside the app somehow.
>
> If I have to write my own program, I probably can, using either C or
> C++ or Visual Basic. I can also run a VBScript from a script in the
> app.
>
> The app uses the FiveWin library, but I only have the most sketchy
> documentation of that. I know it has a lot of functions for doing
> Winders API kinds of things, but I don't know much detail. I have no
> good way to know what functions are already linked into the app, except
> if I know the name of a particular function of interest, I can try it
> and see if it works.
>
> Suggestions, anyone?
>
> -- Jay
> ---------------------------------------
>




dlzc

2007-01-06, 6:55 pm

Dear diogenes:

diogenes wrote:
> Is there a way, within Clipper programs or outside of Clipper programs,
> to keep clocks synchronized on a bunch of in-house locally networked
> machines?
>
> Here is my case in more detail:
> -- I have a Clipper app that runs on multiple machines all at once, in
> a local in-house network.


What kind of network? Windoze or DOS+something?

....
> -- Sometimes, for whatever reason, one machine or another will get it's
> clock set wrong.


Windoze can change the clock at startup, and periodically during the
day, based on desktop-accessible settings. A bad BIOS battery or flaky
BIOS can lose the setting, but usually not when the box is powered up.
A TSR or Windoze "service" can poll an internet service for the
configured time zone.

....
> The app uses the FiveWin library, but I only have the most
> sketchy documentation of that.


If the FiveWin function was not used in the code during original
compilation, there may be no available pointer to the FiveWin function
for your "script" to call.

Better answers will require:
- kind of network?
- internet access to all machines?
- all machines in the same locale / time zone?

David A. Smith

LHSoft@gmail.com

2007-01-06, 6:55 pm

Hi Jay,

I've been using a program called StatBar from http://www.statbar.nl/ to
keep mine computer updated to the correct time from some of the many
internet time servers.

Lasse


On Dec 28, 9:01 pm, "diogenes" <jjaec...@gmail.com> wrote:
> Is there a way, within Clipper programs or outside of Clipper programs,
> to keep clocks synchronized on a bunch of in-house locally networked
> machines?
>
> Here is my case in more detail:
> -- I have a Clipper app that runs on multiple machines all at once, in
> a local in-house network.
> -- They all record lots of data to DBF files with date and time fields.
> -- So it's important that the clocks on all the machines be set to the
> same date and at least approximately the same time.
> -- Sometimes, for whatever reason, one machine or another will get it's
> clock set wrong.
> -- This tends to make a mess of things.
>
> I would like for each machine to re-set its own clock to agree with the
> clock on the file server machine. This might be done in the app itself
> each time the app is started on each machine. Or it might be done
> outside the app, perhaps automatically each time the machine is booted,
> or maybe from some kind of script or batch file each time the app is
> started.
>
> I have one big constraint: I don't have the source code to the app,
> nor a Clipper compiler either. However, the app itself has a script
> interpreter, and I can write a script that the app will run. If there
> is a function to get the date/time from the server's clock, AND if
> there is also a function to set the date/time on the local machine, AND
> if those functions happen to be linked into the app already, then I can
> use them. Otherwise, I will have to do it outside the app somehow.
>
> If I have to write my own program, I probably can, using either C or
> C++ or Visual Basic. I can also run a VBScript from a script in the
> app.
>
> The app uses the FiveWin library, but I only have the most sketchy
> documentation of that. I know it has a lot of functions for doing
> Winders API kinds of things, but I don't know much detail. I have no
> good way to know what functions are already linked into the app, except
> if I know the name of a particular function of interest, I can try it
> and see if it works.
>
> Suggestions, anyone?
>
> -- Jay
> ---------------------------------------


AUGE_OHR

2007-01-06, 6:55 pm

hi,

> -- So it's important that the clocks on all the machines be set to the
> same date and at least approximately the same time.


make 1 PC act as NTP "TimeServer". Buy a DCF77 @ebay (look
for your OS Software-Driver ! ) and connect it to your "TimeServer".

greetings by OHR
Jimmy


diogenes

2007-01-06, 6:55 pm


Yes, all machines involved will be Winders,
mostly XP, maybe some Win98 or NT thrown in.
Typically, there will be one file server with the
other stations feeding off of that (but using some
of their own local files too, so every machine has
its own disk too).

The master will have internet access in most cases,
but I don't think I want to get that involved. I am
consulting for a dealer who sells cash registers to
supermarkets, so we're not dealing with highly
tech-savvy end users. At some stores, there might
not be net access anyway.

At each store, there is one server in some back room
and a bunch of cash registers out front. So they will
all be in the same time zone, and indeed in the same
building. This ISN'T a case of a chain of stores from
coast to coast all connecting to corporate headquarters.

It doesn't even matter too terribly much if the machines
have the right time. Only that they all have the SAME
time, or nearly so.

So the solution I think I am really looking for is for all
the lanes to simply obtain the date and time from the
master station. Each lane should get the server's clock
and set its own clock to match, so that all the date()
and time() calls scattered throughout the app will
get that.

I don't think I'm looking to go out on the net to get
it, or to buy any extra hardware, or anything like
that. Just reading the server's date/time is all
I really want to do.

I know that I can only call functions from my scripts
if they happen to be linked into the app already, so
I always have to keep my fingers crossed and just
try it and hope it works. But first, I am hoping that
such functions exist in the first place, and that I
can learn their names and how to use them, so I
will at least know what to try.

Having the app keep a private record of its own
last known date/time doesn't do the job. That will
allow me to know if the clock has gotten set back,
but not if it has gotten set forward, and does nothing
to fix it if it happens anyway. Having the app display
any kind of message or confirmation is not what we
want either. It should happen automatically and
silently, without bothering the user, who will not usually
be a very computer-savvy person most of the time.
They will just be turning on the power switch and the
machine should boot up ready to run. It's meant
to be a turn-key sort of system.

The whole idea of this request (and some others I have
been posting here lately) is to devise more and more ways
for these systems to take care of themselves automatically
in ways they currently do not, with less and less need for
on-going user interventions and maintenance to fix things
that go wrong, where possible. I am a third-party consultant,
with no access to the source code or a Clipper compiler,
nor to the people in the company that wrote the app
(who don't interest themselves in little niceties like this
anyway). I can only write these add-on scripts, or separate
programs in C or VB or VBScript that would run
outside the app altogether.

This problem with clocks getting set wrong occasionally is
one case in point. It's not a hardware or battery problem.
Apparently, the users will sometimes tweak the clock, probably
not really knowing what they are doing. I think sometimes they
click on the little clock on the task bar and get into the
clock-setting screen and then muck around without really
knowing what they are doing.

If I can't do it with a script in the app, then at least if I could
run a little program outside the app, as part of the startup
procedure or in AUTOEXEC or whatever the XP equivalent
is, that would be good too. So as another alternative,
could someone tell me of a simple little program I could
download that does that, or even just what the necessary
system calls are (if they exist) so I could write my own?

Thanks again.

-- Jay
------------------------------------------

AUGE_OHR

2007-01-06, 6:55 pm

hi,

> Typically, there will be one file server with the


NET TIME
[\\Computername | /DOMAIN[:Name] | /RTSDOMAIN[:Name]] [/SET]
[\\Computername] /QUERYSNTP
[\\Computername] /SETSNTP[:NTP-Serverliste]

greetings by OHR
Jimmy


N:dlzc D:aol T:com \(dlzc\)

2007-01-06, 6:55 pm

Dear diogenes:
"diogenes" <jjaeckel@gmail.com> wrote in message
news:1167360948.128282.202710@k21g2000cwa.googlegroups.com...
>
> Yes, all machines involved will be Winders,
> mostly XP, maybe some Win98 or NT thrown in.
> Typically, there will be one file server with the
> other stations feeding off of that (but using some
> of their own local files too, so every machine has
> its own disk too).


On each machine:
Go to the task bar, bottom right hand side.
Right click on the displayed time, select "Adjust Date/Time".
Select "Date & Time" tab.
Make sure each machine has about the right date, time and time
zone.
You may or may not want to wly update to an internet time
server.

If your machines have some process / user / hardware that
periodically mucks up the date / time, even with this set, you
could write your own separate Clipper program that:
* yields all possible time slices
* unloads any dbf drivers
* each minute Runs the NET TIME command that AUGE_OHR provided to
synchronize with one particular machine.
* add this program to the "Startup" group of all machines.

This sounds like it might do the trick also...
http://www.tucows.com/preview/501600
.... but might require resources you do not have (NTP or SNTP
server).

Either would not require modifying your existing code at all.

David A. Smith


pete@nospam.demon.co.uk

2007-01-06, 6:55 pm

In article <1167332493.137180.189760@h40g2000cwb.googlegroups.com>
jjaeckel@gmail.com "diogenes" writes:

Hi Jay

> Is there a way, within Clipper programs or outside of Clipper programs,
> to keep clocks synchronized on a bunch of in-house locally networked
> machines?

[snip]

Depending on the setup/OS you might be able to put a command
like:

net time \\dbserver /set

in the batch file that starts the app, where \\dbserver is the
server name. I'm not 100% sure of the syntax -- it's a while
since I did this -- but you can get help by entering

net time /?

at a command prompt.

Pete
--
"We have not inherited the earth from our ancestors,
we have borrowed it from our descendants."
antonio

2007-01-06, 6:55 pm

diogenes escreveu:
> Is there a way, within Clipper programs or outside of Clipper programs,
> to keep clocks synchronized on a bunch of in-house locally networked
> machines?


NET TIME can do the job just before your application starts.
Create a batch file to adjust time and start your application. For
exemple:

REM Adjust time
NET TIME \\SERVERNAME /SET /YES
REM Start the application
F:
CD \DATA
APP.EXE

if your servers are configured to act as time servers, your don't even
need to supply the server's name:

NET TIME /SET /YES

will just do the job.

HTH
Ant=F3nio Vila-Ch=E3
Viana do Castelo
Portugal

diogenes

2007-01-06, 6:55 pm


antonio wrote:
> NET TIME can do the job just before your application starts.
> Create a batch file to adjust time and start your application. For
> exemple:
>
> REM Adjust time
> NET TIME \\SERVERNAME /SET /YES


YES! This does it.
Thank you.

We don't run the app from a batch file,
but we CAN write scripts that the app
will run, and we can set it up so the
app will run a start-up script when it
begins, and the script can run
a batch file. That seems to do it.

The script can run the NET TIME command
directly without needing a .BAT file. The
command in our script language is simply:
Shell('NET TIME \\whatever \SET \YES')
and that does it. This runs COMMAND.COM
directly without a batch file and gives it
the NET TIME command.

We noticed an odd thing: When you run this
once, the clock is set as expected, but the
date() and time() functions in the app still
continue to see the time that was there before.
But when we run it twice in a row, then it
works and the date() and time() functions
see the correct time too.

Go figure.

Anyway, we got it working with help from
you and Pete who also mentioned the NET TIME
command. Thank you all.

-- Jay
------------------------------------------------------

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com