[simpits-tech] Lua example for David...

David C. Allen allendc at qwest.net
Thu Jul 24 15:33:35 PDT 2008


At 03:13 PM 7/24/2008 -0700, you wrote:

>Ok, given this information:
>
>
>5600 .0 APUMasterFault
>5600 .1 APUStartAvail
>5600 .2 APUFlap
>5600 .3 APUMaint
>5600 .3 APUStarter // CRJ ????
>5600 .4 APULowPress
>5600 .5 APUPumpFault
>5600 .6 APUFault
>5600 .7 APUGenBus
>
>Offset at 5600 hex is a single byte that is broken into 8 1 bit fields.
>
>Interesting note - they're showing Bit # 3 as two different things...Bug?
>I'll only use APUMaint for this example...
>
>Here's how you work those in Lua:
>
>require "bit";  -- this is the bit field library you'll use.
>                  -- you can download it from
>                 --http://luaforge.net/projects/bit/
>
>-- Define our error constants
>APUMasterFault = 1;
>APUStartAvail = 2;
>APUFlap = 3;
>APUMaint = 4;
>APULowPress = 5;
>APUPumpFault = 6;
>APUFault = 7;
>APUGenBus = 8;

So the above bits are assigned to the "APU_ERROR" single byte @ 5600 ?

So where do you define "APU_ERROR" = Offset at 5600 hex

I am assuming "--" is used to comment a line

>APUError = bit.tobits(CIM:GetNumericValue("APU_ERROR"));
>-- APU_ERROR points to offset 5600
>if APUError[APUMasterFault] == 1 then
>    if CIM:GetOutputState("APU_MASTER_FAULT_LAMP") != 1 then

!= is that "Not equal to"?

== "Equal to"

>      CIM:SetOutputChannel("APU_MASTER_FAULT_LAMP", 1)

Set APU_MASTER_FAULT_LAMP to logic 1

>    end
>else
>    if CIM:GetOutputState("APU_MASTER_FAULT_LAMP") == 1 then
>      CIM:SetOutputChannel("APU_MASTER_FAULT_LAMP", 0)

Set APU_MASTER_FAULT_LAMP to logic 0

>    end
>end



More information about the Simpits-tech mailing list