[r4]: / trunk / IoDrvMEGAIO / ICmpIoDrv / IoDrvReadInputs / svnobj  Maximize  Restore  History

Download this file

42 lines (41 with data), 6.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{attribute 'conditionalshow'}
METHOD IoDrvReadInputs : UDINT
VAR_INPUT
	pConnectorMapList : POINTER TO IoConfigConnectorMap;
	nCount : DINT;
END_VAR
VAR
	i, j : DINT;
	pbyIecAddress: POINTER TO BYTE;
	wDestIndex : WORD;
	bySrcValue : BYTE;
	wSrcIndex : WORD;
	pby : POINTER TO BYTE;
	wParameterByteOffset : WORD;
	pw: POINTER TO WORD;
	dwChannel: UDINT;
IoDrvReadInputs_Count := IoDrvReadInputs_Count + 1;
IF pConnectorMapList = 0 OR nCount = 0 THEN
	IoDrvReadInputs := Errors.ERR_PARAMETER;
	RETURN;
END_IF
FOR i:=0 TO nCount - 1 DO
	IF (pConnectorMapList[i].dwNumOfChannels = 0) THEN
		CONTINUE;
	END_IF
		pbyIecAddress := pConnectorMapList[i].pChannelMapList[j].pbyIecAddress;
		IF (pConnectorMapList[i].pChannelMapList[j].pParameter^.dwDriverSpecific = 0) THEN
			IF (pConnectorMapList[i].pChannelMapList[j].wSize = 1) THEN
					SysCpuSetBit2(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8);			
    			{ELSE}    
					SysCpuResetBit2(ADR(pbyIecAddress[wDestIndex]), pConnectorMapList[i].pChannelMapList[j].wIecAddressBitOffset MOD 8);			
				pbyIecAddress[wDestIndex] := WORD_TO_BYTE( SHR(_TestFB.byDigitalIn, pConnectorMapList[i].pChannelMapList[j].wParameterBitOffset) );
			END_IF
		END_IF
		// Analog In
			dwChannel := pConnectorMapList[i].pChannelMapList[j].pParameter^.dwParameterId - 1100;
			pw := pbyIecAddress;
			pw^ := _TestFB.awAnalogIn[dwChannel];
	END_FOR
END_FOR
IoDrvReadInputs := Errors.ERR_OK;