Introduction
============
Program CycleSvc can periodically (cyclically) launch Recon with proper command
line parameters containing information about task, desired date and time and
desired length of interval.
Recon can be launched in two modes: Task mode and Batch mode.
All necessary information is stored in ini (configuration) file.

Task mode
---------
See below Configuration [tasks] and [task_i]
In this mode Recon solves always one task with one timestamp. In Recon GUI it
is done via Task - Import/export - Import and Calculate - Run

Batch mode
----------
See below Configuration [batches] and [batch_i]
In this mode Recon solves always one task with starting and ending timestamp.
In Recon GUI it is done via Task - Import/export - Imports and exports.
Period is defined in task file (Settings - Physical units, Balancing period).
I need to know this period (intervallength in my ini file) to can properly
create times part in comandline.
There are batch modes:
- daily batch launches Recon with timestamps begin of "yesterday" (midnight) and
  end of "yesterday" (midnight)
- monthly batch launches Recon with timestamps begin of last month (midnight)
  and end of last month (midnight). If it is to launch later phase is greater
  than 1440 (minutes in the day). See configuration.

Package
=======
Package consists of these files:
1. CycleSvc.exe (program)
2. CycleSvc.ini (sample configuration)
3. README.txt (this file)

Use modes
=========
Application can be used as program (interactively) or service (daemon, WinNT or
higher). Interactive use brings no advantage, user can only start or stop
"looking the watch". Program mode is useful in only these cases:
1. User is not allowed install or controll services
2. Application will be used only temporarily
3. Application will launch Recon residing (or using) network drives and there
  is not possible to configure this program to run under some user's account.

Installation in program mode
===========================
Program needs no installation. It is only copied into some directory with its
config file (CycleSvc.ini). We prefere directory on local drive but it can be
on network, too.

Installation in service mode
===========================
Program should be placed in some directory on local drive, e.g. c:\recon\cycler.
Then it must be run with parameter -install (or /install). If recon.exe or some
recon task (some_file.BDT) is in network, service cannot run in Local System
account. In such cases must be Windows Service manager launched and service must
be configured to use account of some user with proper network permissions.
Service name is "ReconCycler".

Uninstallation in service mode
=============================
Service can be unintalled by running program with parameter -uninstall.

Configuration
=============
There is no configuration tool. The cyclesvc.ini file must be modified by
means of text editor like Notepad. This file is an ordinary Windows ini file
with several group (sections). It can be edited even when the application is
running: the application read its content repeatedly at the beginning of each
hour (within its first 10 seconds). If the file is not valid (some exename or
taskname is not defined - it can be caused by inproper numbering of sections),
the program stops itself a writes information about it into logfile. The user
must read logs after changing configuration.

Group "[program]"
-----------------
There are keys:
"mod", string. Possible values are "riis" (default), "phd", "pi" or "ip21". Must
be set if "runningtag" is used (see [task_i] below). ip21 mode was not tested.
"debug", boolean {0|1} for log verbosity, default 0 (false)


Group "[tasks]"
---------------
There is only one key "count" of type integer. It is number of Recon tasks that
will be cyclicaly solved. 
Example:
count=3

Groups "[task_i]"
-----------------
Each solved task has its own group, "i" is integer between 1 and "count"
In each group there are these keys:
"launchperiod", integer. How often (in minutes) will be Recon launched,
ususally 60.
"phase", integer. Phase (delay) in minutes when Recon is launched. Ensure that
data exist and no too many instances of Recon are running. Usually some small
number, e.g. 10.
  Important! If start of interval is used for timestamps (Recon's default) phase
  must be greater than launchperiod.
"intervallength", integer. Length of time interval where data will be averaged,
usually same as "launchperiod".
"exename", string. Filename with full path, no quotas needed.
"taskname", string. Filename with full path, no quotas needed.
"exporttohistory", boolean (0/1). 1 if values should be written into history
table (MDB file). Used usually for task debugging.
"exporttoexternal", boolean (0/1). 1 if values should be exported into
external data source, usually historian.
"runningtag", string, no quotas needed. If not empty task is solved only when
its value is >0. Program must be in phd or pi mode.

Example:
[task_2]
launchperiod=60
phase=15
intervallength=60
exename=S:\Recon70\Recon.exe
taskname=S:\Recon70\TASK\AVD\AVD-EXCH.BDT
exporttohistory=0
exporttoexternal=1
runningtag=

Group "[batches]"
-----------------
There is only one key "count" of type integer. It is number of Recon tasks that
will be solved in batch mode.
Example:
count=3

Groups "[batch_i]"
------------------
Each solved batch task has its own group, "i" is integer between 1 and "count"
In each group there are these keys:
"type", integer, 0 (default) daily, 2 monthly
"day", integer, 1 (default) monday .. 7 sunday, used only for type 1 (weekly)
  if day is 6 task will be solved on saturday with data from last friday to this
  friday
"intervallength", integer, in minutes, length of interval of averages of data
  and count period. This interval is to be defined in BDT file - here it is used
  for start and end time calculation. See "margins" below
"margins", integer, 0 exclude both, 1 include start (default), 2 include end, 3 include both
  Examples (for intervallength=15)
  margins=0 -> times 00:15 - 23.45
  margins=1 -> times 00:00 - 23.45
  margins=2 -> times 00:15 - 00:00
  margins=3 -> times 00:00 - 00:00
  When settings margins consider timestamps - see phase bellow.
"phase", integer, phase (delay, after midnight) in minutes
  If timestamp for task (set in Recon's data sources) is START of interval
  phase should be greater than intervallength, e.g. for hourly task something
  like 65 or so
"exename", string. Filename with full path, no quotas needed. Same as for [task_i].
"taskname", string. Filename with full path, no quotas needed. Same as for [task_i].
"exporttohistory", boolean (0/1). 1 if values should be written into history
  table (MDB file). Used usually for task debugging. Same as for [task_i].
"exporttoexternal", boolean (0/1). 1 if values should be exported into
  external data source, usually historian. Same as for [task_i].


Running as program
==================
There can be only one instance of program running (on one computer) but it can
launch several Recon instances. Program has simple menu with these items:
"Launch - Start" (Ctrl+S) starts work
"Launch - Pause" (Ctrl+P) pauses work
"Launch - Resume" (Ctrl+R) continues paused work
"Launch - Stop" (Ctrl+O) stops work
"Launch - ReRead ini" (no shortcut) forces reading of config file
"Exit" (Ctrl+Q) exits program
Status bar has three panels:
1. Text Enabled/Disabled is set after each reading and parsing config file.
2. Text Stopped/Paused/Running shows state of program.
3. Information about last Recon launch (date, time and number of task).

Note
----
If CycleSvc is installed as service (see Installation in service mode) it can not
be launched as program.

Commandline parameters
----------------------
If run without parameters, program after launch does nothing. There are two
possible parameters which can be used for "automation":
Parameter A:
Abbreviation of "automatic", program immediately starts work (if configuration
is O.K.)
Parameter H:
Abbreviation of "hidden", program immediately starts work (if configuration
is O.K.) AND hides its window. In this mode program is visible only in Task
Manager on Process tab.
Notes:
  Examples: cyclesvc.exe -a or cyclesvc.exe -h, delimiter can be - (minus) or
  / (slash), parameter is not case sensitive (-a is the same as /A).
  If configuration is not O.K. program behave like no parameter is used.

Running as service
==================
Properly installed and configured service (daemon) can be controlled via Service
manager or by use command net:
"net start ReconCycler",
"net pause ReconCycler",
"net continue ReconCycler",
and "net stop ReconCycler"
to start, pause, resume or stop repectively. In service mode is no possibility
to force reading of ini file, user must wait till service will do it itself
after the whole hour.

Log files
=========
Application writes its own log files in its directory. Their names are 
"cyclesvc.0dd.txt" where "dd" is day of the month. After midnight old file with
the same day is erased if exists. In logs is all usefull and much useless
information. We advice sometimes look into logs.
