COMPILE FUNCTION Comm_Test_Point_Map(Instruction, Parm1)

/*
	Commuter module for Test_Point_Map window
	
	05/16/2006 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, Center_Window
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Center_Window, Popup, Collect.Ixvals
DECLARE FUNCTION Send_Message

$INSERT POPUP_EQUATES

EQU CRLF$	TO \0D0A\

EQU COL$POINT_ID	TO 1
EQU COL$RESULT_NO	TO 2

EQU COL$MAP_LABEL	TO 1

EQU POINT$T		TO 4:@FM:1
EQU POINT$TC	TO 4:@FM:2
EQU POINT$C		TO 4:@FM:3
EQU POINT$BC	TO 4:@FM:4
EQU POINT$B		TO 4:@FM:5
EQU POINT$R		TO 2:@FM:3
EQU POINT$RC	TO 3:@FM:3
EQU POINT$LC	TO 5:@FM:3
EQU POINT$L		TO 6:@FM:3

$INSERT APPCOLORS

ErrTitle = 'Error in Comm_Test_Point_Map'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Instruction = 'Create' 			; GOSUB Create
	CASE Instruction = 'Clear'				; GOSUB Clear
	CASE Instruction = 'Refresh'			; GOSUB Refresh
	CASE Instruction = 'Read'				; GOSUB Read
	CASE Instruction = 'LUTPMap'			; GOSUB LUTPMap
	
	CASE 1
		ErrorMsg = 'Unknown Instruction passed to routine.'
		ErrMsg(ErrorMsg)
END CASE

RETURN Result



* * * * * * *
Create:
* * * * * * *

Center_Window(@WINDOW)

IF Parm1 NE '' THEN
	obj_AppWindow('LoadFormKeys',@WINDOW:@RM:Parm1)
END

GOSUB Refresh


RETURN


* * * * * * *
Clear:
* * * * * * *

GOSUB Refresh

RETURN


* * * * * * *
Read:
* * * * * * *


GOSUB Refresh

RETURN


* * * * * * *
Refresh:
* * * * * * *

RecID = Get_Property(@WINDOW,'ID')


IF INDEX(RecID,'ASM',1) OR RecID = '' THEN

	Set_Property(@WINDOW:'.POINT_MAP','ENABLED',0)
	
	FOR Row = 1 TO 5
		Set_Property(@WINDOW:'.POINT_MAP','CELLPOS','',1:@FM:Row)
		FOR Col = 2 TO 6
			Set_Property(@WINDOW:'.POINT_MAP','CELLPOS','',Col:@FM:Row)
			stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',Col,Row,GREEN$)
		NEXT Col
	NEXT Row
	
END ELSE

	* Not an ASM reactor so load the Map Control
	
	Set_Property(@WINDOW:'.POINT_MAP','ENABLED',0)
	
	MapRowLabels = 'T':@VM:'TC':@VM:'Center':@VM:'BC':@VM:'B'
	
	FOR Row = 1 TO 5
		Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',MapRowLabels<1,Row>,1:@FM:Row)
		FOR Col = 2 TO 6
			Set_Property(@WINDOW:'.POINT_MAP','CELLPOS','',Col:@FM:Row)
			stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',Col,Row,GREEN$)
		NEXT Col
	NEXT Row
	
	PointList = Get_Property(@WINDOW:'.POINT_ID','LIST')
	
	FOR I = 1 TO COUNT(PointList,@FM) + (PointList NE '')
		PointID = PointList<I,1>
		ResultNo = PointList<I,2>
		BEGIN CASE
			CASE PointID = 'T'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$T)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',4,1,YELLOW$)
				
			CASE PointID = 'TC'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$TC)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',4,2,YELLOW$)
				
			CASE PointID = 'Center'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$C)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',4,3,YELLOW$)
				
			CASE PointID = 'BC'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$BC)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',4,4,YELLOW$)
				
			CASE PointID = 'B'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$B)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',4,5,YELLOW$)
				
			CASE PointID = 'R'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$R)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',2,3,YELLOW$)
				
			CASE PointID = 'RC'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$RC)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',3,3,YELLOW$)
				
			CASE PointID = 'LC'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$LC)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',5,3,YELLOW$)
				
			CASE PointID = 'L'
				Set_Property(@WINDOW:'.POINT_MAP','CELLPOS',ResultNo,POINT$L)
				stat = Send_Message(@WINDOW:'.POINT_MAP','COLOR_BY_POS',6,3,YELLOW$)
				
		END CASE
					
	NEXT I
END
	
RETURN


* * * * * * *
LUTPMap:
* * * * * * *

	
TPMapKey = Popup(@WINDOW,'','TEST_POINT_MAP')

IF TPMapKey = '' THEN RETURN

obj_AppWindow('LoadFormKeys',@WINDOW:@RM:TPMapKey)


RETURN

