HCCU internal data

{
	IData - Internal data
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	$24 00 staticmsg[0..51]
 	0	Version
 	1	Subversion
 	2..5	Serial as stored in PIC
 	6..7	Memavail Segment
 	8..51	Just a message
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	$24 01 runtimemsg[0..8]
 	0..3	Runtime in ticks, approx 55ms each
 	4..5	approx #RCD's 
 	6	#tasks serving network commands
 	7	#tasks serving quickmap requests
 	8	#tasks serving unimap
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	$24 02 statisticmsg[0..21]
 	0..1	#MRx pack all
	2..3	#MRx len fail
	4..5	#MRx crc fail
	6..7	#MRx code fail
 	8..9	#QMap req
	10..11	#QMap fail
	12..13	#poll done
 	14..15	#poll fail
 	16..17	#irr AN rep
 	18..19  #its
	20..21	#recover
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
 	$24 03 xstatusmsg[0..8]
	0..1	Masterbase adress
	2	Masterstatus
	3	Nettimeout
	4	UMap low sweep
	5	UMap high sweep
	6	UMap step
	7	UMap delay
	8	Poll delay
	9	AutoswitchOff :HCCU switch off in fail
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	$24 04 xparametermsg as xstatusmsg
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
        Masterstatus as :
        NetOn	    =$80
        NoMaster    =$40
        PollEnabled =$20
        MapEnabled  =$10
        ISOCRC      =$08
        ScanEnabled =$04  new - not yet working 
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	Access : $24 04
	InternalMessage :[0.. ] all items are hibyte first
	0..1	:Seg(memavail)    	:WORD
	2..3	:#MMURxPackets all	:WORD
	4..5	:#MMURxPackets lenfail	:WORD
	6..7	:#MMURxPackets crcfail	:WORD
	8..9	:#MMURxPackets codefail	:WORD
	10..11	:QMaps req		:WORD
	12..13	:Qmaps fail		:WORD
	14..15  :poll done		:WORD
	16..17	:poll fail		:WORD
	18..19  :irregular		:WORD
	20..21	:recover		:WORD
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	$24 05 
	Multimaster :[0.. ] all items are hibyte first
	0       :Nr of other masters detected
	1..2    :Node Master 1
	3..4    :Node Master 2
	5..6    :Node Master 3
	7..8    :Node Master 4
	9..10   :Node Master 5
	11..12  :Node Master 6
	13..14  :Node Master 7
	15..16  :Node Master 8
	currently limited to 8 other masters, change 
	CONST MaxOtherMaster below
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	$24 06 IDList del, see ictask
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	change 20/jan/95 :
	 implemented AutoswitchOff as 9. field in MDCUXPara/MDCUXStatus
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
	Created		:8/Feb/92
	Last Update	:9/dec/93

	Is updated version of :
	컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
}
{$E-,N-}
{.$D-,L-}
UNIT IData;

INTERFACE

USES RTKernel,{$IFNDEF PC}V25Init,{$ENDIF}ANList;

CONST
 SoftVersion=1;		{ version of this software }
 SoftSub=4;		{ subversion of this software }
 UMapLowSweep=9;	{ lower sweep boundary, lowest probability }
 UMapHighSweep=15;	{ upper sweep boundary, highest probability }
 UMapStepCnt=4;		{ nr of tries on the same probability }
 UMapDelay=9;		{ preset delay between two umaps }
 PollDelay=9;		{ preset delay between two polls }
 ERetry=2;		{ preset retry on invalid }
 AutoswitchOffDefault=0;{ infinite }
{$IFDEF PC }
 SerialNumber=$00000001; { will be in PIC }
{$ENDIF}
  JustAMessageInv='*****************************************';

 MDCUXStatusBufferLen=14;
 MDCUXInternalLen=20;
 MaxOtherMaster=8;
 MDCUMultimasterlen=MaxOtherMaster*2+1;
VAR
 StaticMsg:ARRAY[0..49]OF BYTE;
 RuntimeMsg:ARRAY[0..8]OF BYTE;
 StatisticMsg:ARRAY[0..21]OF BYTE;
 XstatusMsg:ARRAY[0..9]OF BYTE;
 MDCUStatusBuffer :ARRAY[0..14]OF BYTE;
 JustAMessage:STRING[41];
 InternalMessage :ARRAY[0..MDCUXInternalLen-1]OF BYTE;
 MultimasterMsg :ARRAY[0..MDCUMultimasterlen-1]OF BYTE;
 OtherMasters:ARRAY[0..MaxOtherMaster-1]OF WORD;
 NetEnabled :BOOLEAN;	{ wished status of network }
 NetOn :BOOLEAN;	{ current status of network }
 SeqOnCnt:BYTE;		{ number of task accessing the network excl.Control }
 Pollon,lastseq:BYTE; { debug }
 NoMaster:BOOLEAN;	{ set /reset by Net Control Task }
 OtherMasterCnt:BYTE;
 AutoswitchOff:BYTE;	{ changed by ICtask }
 ISOCRC:BOOLEAN;        { set/ reset by MRxTask - unused now }
 PollEnabled,MapEnabled,ScanEnabled:BOOLEAN;{ set/ reset by ICTask }
 mema:WORD; { memavail ,seg }
 mmurxa,
 mmurxl,
 mmurxc,
 mmurxd:WORD;
 qmapcnt:WORD; { nr of qmaps req }
 qmapfail:WORD; { nr of qmaps fail }
 NRec,
 irrcnt,
 pollcnt,
 pollfail,itscnt:WORD;
 UMapLowS,UMapHighS,UMapStepC,UMapD,PollD:BYTE;

{PROCEDURE BuildXStatus(time:LONGINT;Entries:WORD);}
PROCEDURE BuildInternal;
PROCEDURE XSetMasterTimeout(t:BYTE);
PROCEDURE SetOtherMaster(N:WORD);
PROCEDURE BuildMultiMasterMsg;
PROCEDURE BuildStaticMsg;
PROCEDURE BuildRuntimeMsg(Entries:WORD;c,d,e:BYTE);
PROCEDURE BuildStatisticMsg;
PROCEDURE BuildXstatusMsg;


IMPLEMENTATION
{.$DEFINE SingleMaster}
{컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴}
PROCEDURE Init;
VAR i:BYTE;
BEGIN
 MDCUStatusBuffer[0]:=0;	{ Init Error Code }
 MDCUStatusBuffer[1]:=SoftVersion;	{ software version }
 MDCUStatusBuffer[2]:=SoftSub;	{ software subversion }
 MDCUStatusBuffer[3]:=$80;	{ handshake byte }
 MDCUStatusBuffer[4]:=0;	{ net buffer size high }
 MDCUStatusBuffer[5]:=$80;	{ net buffer size low }
 MDCUStatusBuffer[6]:=$50;	{ max net packet size }
 MDCUStatusBuffer[7]:=ERetry;	{ retries on invalid reply }
 MDCUStatusBuffer[8]:=0;	{ sum of retries- not used here }
 MDCUStatusBuffer[9]:=0;	{ successful polls 1 - not used here }
 MDCUStatusBuffer[10]:=0;	{ successful polls 2+ - not used here }
 MDCUStatusBuffer[11]:=$09;	{ Delay base = times 100ms }
 MDCUStatusBuffer[12]:=0;	{ not used here }
 MDCUStatusBuffer[13]:=0;       { not used here }
 MDCUStatusBuffer[14]:=0;       { not used here }
{$IFDEF SingleMaster}
 NetEnabled:=TRUE; { start after powerup }
{$ELSE}
 NetEnabled:=FALSE; { wait after power up }
{$ENDIF}
 NetOn:=FALSE;
 NoMaster:=TRUE;
 ISOCRC:=FALSE;
 PollEnabled:=TRUE;
 MapEnabled:=TRUE;
 ScanEnabled:=FALSE;
{ PollEnabled:=FALSE;
 MapEnabled:=FALSE;}
 JustAMessage:=JustAMessageInv;
 FOR i:= 1 To 41 DO JustAMessage[i]:=chr(Not ord(JustAMessage[i]));
{ BuildXStatus(0,0);}
 qmapcnt:=0;qmapfail:=0;mmurxa:=0;mmurxl:=0;mmurxc:=0;mmurxd:=0;
 pollcnt:=0;pollfail:=0;irrcnt:=0;SeqOnCnt:=0;itscnt:=0;Pollon:=0;NRec:=0;
 { multimastermsg }
 FOR i:= 0 To MDCUMultimasterlen-1 DO MultimasterMsg[i]:=0;
 FOR i:= 0 To MaxOtherMaster-1 DO OtherMasters[i]:=0;
 OtherMasterCnt:=0;
 UMapLowS:=UMapLowSweep;
 UMapHighS:=UMapHighSweep;
 UMapStepC:=UMapStepCnt;
 UMapD:=UMapDelay;
 PollD:=PollDelay;
 lastseq:=$FF;
 AutoswitchOff:=AutoswitchOffDefault; { =infinite }
END;


PROCEDURE BuildInternal;
BEGIN
 InternalMessage[0]:=hi(mema); { Seg(memavail) }
 InternalMessage[1]:=lo(mema);
 InternalMessage[2]:=hi(mmurxa); { mmu rx all }
 InternalMessage[3]:=lo(mmurxa);
 InternalMessage[4]:=hi(mmurxl); { mmu rx lenfail }
 InternalMessage[5]:=lo(mmurxl);
 InternalMessage[6]:=hi(mmurxc); { mmu rx crcfail }
 InternalMessage[7]:=lo(mmurxc);
 InternalMessage[8]:=hi(mmurxd); { mmu rx codefail }
 InternalMessage[9]:=lo(mmurxd);
 InternalMessage[10]:=hi(qmapcnt); { QMaps req }
 InternalMessage[11]:=lo(qmapcnt);
 InternalMessage[12]:=hi(qmapfail); { Qmaps fail }
 InternalMessage[13]:=lo(qmapfail);
 InternalMessage[14]:=hi(pollcnt); { poll req }
 InternalMessage[15]:=lo(pollcnt);
 InternalMessage[16]:=hi(pollfail); { poll fail }
 InternalMessage[17]:=lo(pollfail);
 InternalMessage[18]:=hi(irrcnt); { irregular net packets }
 InternalMessage[19]:=lo(irrcnt);
END;
PROCEDURE XSetMasterTimeout(t:BYTE);
BEGIN
 XstatusMsg[3]:=t;
{ MDCUXStatusBuffer[11]:=t; old }
END;
{ next not yet tested }
PROCEDURE SetOtherMaster(N:WORD);
VAR i:BYTE;
BEGIN
 IF (OtherMasterCnt<(MaxOtherMaster-1)) THEN
  BEGIN
   i:=0;
   WHILE (OtherMasters[i]<>N)AND(i<(MaxOtherMaster-1)) DO Inc(i);
   IF (OtherMasters[i]=0) THEN
    BEGIN
     Inc(OtherMasterCnt);
     OtherMasters[i]:=n;
    END;
  END;
END;
{ next not yet tested }
PROCEDURE BuildMultiMasterMsg;
VAR i:BYTE;
BEGIN
 MultimasterMsg[0]:=OtherMasterCnt;
 FOR i:=0 TO MaxOtherMaster-1 DO
  BEGIN
   MultimasterMsg[1+2*i]:=hi(OtherMasters[i]);
   MultimasterMsg[2+2*i]:=lo(OtherMasters[i]);
  END;
END;
PROCEDURE BuildStaticMsg;
VAR
 l:LONGINT;
 b:ARRAY[1..4]OF BYTE ABSOLUTE L;
 j:BYTE;
BEGIN
 StaticMsg[0]:=SoftVersion;
 StaticMsg[1]:=SoftSub;
 L:=SerialNumber;
 StaticMsg[2]:=b[4];
 StaticMsg[3]:=b[3];
 StaticMsg[4]:=b[2];
 StaticMsg[5]:=b[1];
 StaticMsg[6]:=hi(mema); { Seg(memavail) }
 StaticMsg[7]:=lo(mema);
 FOR j:=1 TO 41 DO StaticMsg[7+j]:=ord(JustAMessage[j]);
END;
PROCEDURE BuildRuntimeMsg(Entries:WORD;c,d,e:BYTE);
VAR
 l:LONGINT;
 w:ARRAY[1..2]OF WORD ABSOLUTE L;
 b:ARRAY[1..4]OF BYTE ABSOLUTE L;
BEGIN
 l:=RTKERNEL.Gettime;
 RuntimeMsg[0]:=b[4];
 RuntimeMsg[1]:=b[3];
 RuntimeMsg[2]:=b[2];
 RuntimeMsg[3]:=b[1];
 w[1]:=Entries;
 RuntimeMsg[4]:=b[2];
 RuntimeMsg[5]:=b[1];
 RuntimeMsg[6]:=c;
 RuntimeMsg[7]:=d;
 RuntimeMsg[8]:=e;
END;
PROCEDURE BuildStatisticMsg;
BEGIN
 StatisticMsg[0]:=hi(mmurxa); { mmu rx all }
 StatisticMsg[1]:=lo(mmurxa);
 StatisticMsg[2]:=hi(mmurxl); { mmu rx lenfail }
 StatisticMsg[3]:=lo(mmurxl);
 StatisticMsg[4]:=hi(mmurxc); { mmu rx crcfail }
 StatisticMsg[5]:=lo(mmurxc);
 StatisticMsg[6]:=hi(mmurxd); { mmu rx codefail }
 StatisticMsg[7]:=lo(mmurxd);
 StatisticMsg[8]:=hi(qmapcnt); { QMaps req }
 StatisticMsg[9]:=lo(qmapcnt);
 StatisticMsg[10]:=hi(qmapfail); { Qmaps fail }
 StatisticMsg[11]:=lo(qmapfail);
 StatisticMsg[12]:=hi(pollcnt); { poll req }
 StatisticMsg[13]:=lo(pollcnt);
 StatisticMsg[14]:=hi(pollfail); { poll fail }
 StatisticMsg[15]:=lo(pollfail);
 StatisticMsg[16]:=hi(irrcnt); { irregular net packets }
 StatisticMsg[17]:=lo(irrcnt);
 StatisticMsg[18]:=hi(itscnt); { itsreq }
 StatisticMsg[19]:=lo(itscnt);
 StatisticMsg[20]:=hi(NRec);   { recovery }
 StatisticMsg[21]:=lo(NRec);
END;
PROCEDURE BuildXstatusMsg;
VAR
 l:LONGINT;
 w:ARRAY[1..2]OF WORD ABSOLUTE L;
 b:ARRAY[1..4]OF BYTE ABSOLUTE L;
 bl:BOOLEAN ABSOLUTE L;
BEGIN
 XstatusMsg[0]:=hi(ANLIST.BaseAdr);
 XstatusMsg[1]:=lo(ANLIST.BaseAdr);
 b[1]:=0;
 IF (NetOn) THEN b[1]:=b[1] or $80;
 IF (NoMaster) THEN b[1]:=b[1] or $40;
 IF (PollEnabled) THEN b[1]:=b[1] or $20;
 IF (MapEnabled) THEN b[1]:=b[1] or $10;
 IF (ISOCRC) THEN b[1]:=b[1] or $08;
 IF (ScanEnabled) THEN b[1]:=b[1] or $04;
 XstatusMsg[2]:=b[1];
{ XstatusMsg[3]:= set otherwise :NetTimeout }
 XstatusMsg[4]:=UMapLowS;
 XstatusMsg[5]:=UMapHighS;
 XstatusMsg[6]:=UMapStepC;
 XstatusMsg[7]:=UMapD;
 XstatusMsg[8]:=PollD;
 XstatusMsg[9]:=AutoswitchOff;
END;

{컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴}
BEGIN	{ autoinit of this unit}
 Init;
END.	{ unit }



home

last updated 4.dec.99


Copyright (99,2000) Ing.Büro R.Tschaggelar