s5dialog.exe
============

1. The purpose of the program

This program implements a small subset of s5 like plc programming
language (AWL). You can use it to learn and understand to program
in logic. 

2. Installation
Just unzip the zip file with full directory structure preserved. 
It will unpack everything under \msdevstd\projects\s5dialog
The program is  under ..\release\s5dialog.exe.
It requires the mfc40.dll in the windows\system or winnt\system32 
directory. You can download it from this side:
We now have the MFC40 runtimes here at Simtel.Net:

ftp://ftp.simtel.net/pub/simtelnet/win95/dll/
 Filename      Size   Date    Description
mfc40.zip     592860  981013  MFC40 runtime files - mfc40.dll, msvcrt40.dll

Archive:  /simtelnet/win95/dll/mfc40.zip
Distributed by the Simtel.Net(sm) world-wide network
  Length     Date   Time    Name
 --------    ----   ----    ----
        0  10-07-98 14:43   mfc40/
   933888  05-06-98 20:01   mfc40/MFC40.DLL
   326656  03-18-97 00:00   mfc40/MSVCRT40.DLL
      812  10-13-98 10:37   mfc40.txt
      129  10-13-98 10:34   version.txt
 --------                   -------
  1261485                   5 files

It must be manually copied to the appropiate directory! The ease the loading
of for ex. my.awl, copy this file to c:\ (root directory).
The full source code in VC++4.0 is also included. Please keep in
mind, the various code fragments have been used from other people.
The codes came from www.codeguru.com. To show this, I have included
a message in the credit scrolling window. Individual copyrights my
apply. However, this sources are intented to by copied and included
by other programmers, so there should by no problem at all.

3. Status of program. 
Freeware with full copyright (c) Peter Sieg. For personal purpose
free to use and modify. 

4. Distribution status.
Freely redistributable.

5. Author contact.
E-Mail:  Peter.Sieg.PS@hr-gmbh.de

6. This program requires W95/98 or WinNT.

=====================================================================

UN A 0 0	Toggles A 0 0
= A 0 0
U E 0 0		Set A 0 1
= A 0 1
U E 0 1		Set A 0 2
= A 0 2
UN M 0 0	Marker, to do this only once
L K 18 0	Load 18 into accu
S Z 0 0
S T 0 0
S M 0 0
U M 0 0
U E 0 2
Z V 0 0
Z V 0 1
U M 0 0
U E 0 3
Z R 0 0
U M 0 0
U E 0 4
Z R 0 1
BE

This awl will be correct handled. The comments to the right will be
ignored! Important are the 4 fields:
Operation Operand Baustein/deviceno Bitno
This 4 fields MUST be separated by exactly one blank/space character!

Explanations to s5dialog.c
==========================
There is only a limetted syntax check at loadling of an awl.

E/A/M/T/Z Bausteine/devices range=[0-1]; Bitno range=[0-7];
Following instructions are implemented:

Operation	Operand		Result		Conditions
U		E/A/M/T/Z	vkb;vkl		vka and vkl or vku
UN		E/A/M/T/Z	vkb;vkl		not vka and vkl or vku
O		E/A/M/T/Z	vkb;vkl		vka or vkl
ON		E/A/M/T/Z	vkb;vkl		not vka or vkl
L		K		accu=baustein	vkl=1
S		T/Z		=accu		vkl=1
		E/A/M		=1		vkl=1
R		E/A/M/T/Z	=0		vkl=1
Z		V		Z++;		vkl=1; Z < MAXINT;
		R		Z--;		vkl=1; Z > 0;
=		E/A/M		E/A/M=vkl	nothing
BE		keine		(vku=1;vkl=1;if (T* > 0) T*--;) /*PseudoTimer*/

Also Operands (only update b_vka!):
		yy		Year 2-digits!!
		yn		Month
		yw		Week (only near result code implemented!)
/* now calc week of year - not correct, but simple substitution! */
  yw = (((yn - 1) * 30 + yd) / 7) + 1; /* (--month * 30 (days) + days) / 7 + 1*/
		yd		Day
		yo		Day of Week So=0,Mo=1..Fr=5,Sa=6
		yh		hour
		ym		Minute
		ys		Second
b_vka is true, if yX is bigger then deviceno.
example:
U YS 30 0	if second is 31-59
= A 0 0		then A0.0 = 1 (will be true)
UN A 0 0	and therefore A0.1 = 0 (will be false)	
= A 0 1
BE		A0.0 and A0.1 will toggle in 30 seconds...

Output a[0][0-7] to default port 0x3bc. Input e[0][0-7] from port 0x3bc+1.
Other Ports: 0x278, 0x378.

Attention: Due to limitation in the MFC version, no outputs implemented.
But there is a console version as msdos stub linked, that has full output
to external port aktivated. So try out your awl program with the MFC version
first, than start it under msdos console windows...


Interface for external port signals (example):
Pin: 2-9 = D0-D7
Out: ---|>*---|<|---==---+5V
     1/6 7406 Led  330ohm

Pin: 10-13 Only this 4 inputs implemented.
In : --*--|\--- GND
       |  Switch
      ||| 10kohm
       |
       +5V 


---------------------------------------------------------------------
Die AWL oben, wird korrekt abgearbeitet. Die Kommentare rechts werden
ignoriert! Wichtig sind die 4 Felder:
Operation Operand Baustein Bitnr
die jeweils - exakt - durch eine Leerzeichen getrennt sein mssen!


Erlaeuterungen zu s5.c
======================

Eingeschrnkte Syntaxpruefung beim Laden einer AWL.

E/A/M/T/Z Bausteine=[0-1]; Bitnr=[0-7];
Folgende Anweisungen sind implementiert

Operation	Operand		Ergebnis	Bedingung
U		E/A/M/T/Z	vkb;vkl		vka Und vkl Oder vku
UN		E/A/M/T/Z	vkb;vkl		Nicht vka Und vkl Oder vku
O		E/A/M/T/Z	vkb;vkl		vka Oder vkl
ON		E/A/M/T/Z	vkb;vkl		Nicht vka Oder vkl
L		K		accu=baustein	vkl=1
S		T/Z		=accu		vkl=1
		E/A/M		=1		vkl=1
R		E/A/M/T/Z	=0		vkl=1
Z		V		Z++;		vkl=1; Z < MAXINT;
		R		Z--;		vkl=1; Z > 0;
=		E/A/M		E/A/M=vkl	keine
BE		keine		(vku=1;vkl=1;if (T* > 0) T*--;) /*PseudoTimer*/

Als Operanden (nur update b_vka!) werden auch verarbeitet:
		yy		Jahr 2-stellig!!
		yn		Monat
		yw		Kalenderwoche (nocht nicht richtig implementiert)
/* now calc week of year - not correct, but simple substitution! */
  yw = (((yn - 1) * 30 + yd) / 7) + 1; /* (--month * 30 (days) + days) / 7 + 1*/
		yd		Tag
		yo		Wochentag So=0,Mo=1..Fr=5,Sa=6
		yh		Stunde
		ym		Minute
		ys		Sekunde
b_vka ist wahr, wenn yX grer als baustein ist.
z.B.
U YS 30 0	wenn Sekunde 31-59 ist
= A 0 0		ist A0.0 = 1
UN A 0 0	damit ist A0.1 = 0	
= A 0 1
BE		A0.0 und A0.1 werden im 30s Wechsel gesetzt...

Ausgabe a[0][0-7] an default port 0x3bc. Eingabe e[0][0-7] von port 0x3bc+1.
Andere Ports: 0x278, 0x378.
Wenn debug level beim Aufruf von s5 <awl> <debug_level> grer/gleich 200 ist,
wird debug level = 0 gesetzt und der Parameter als HEXWERT fr den Port verwendet!
z.B. s5 my.awl 278
Startet s5 mit Datei my.awl und Port 0x278

Interface
Pin: 2-9 = D0-D7
Out: ---|>*---|<|---==---+5V
     1/6 7406 Led  330ohm

Pin: 10-13 Nur diese 4 Inputs unterstuetzt.
In : --*--|\--- GND
       |  Schalter
      ||| 10kohm
       |
       +5V 
