The online racing simulator
How to substract variable Flags? OutGauge
Hi all!

I am recently active with VB6 and making a application that is receiving the OutGauge UDP packets.

With VB6 i have created a Virtual dashboard that will visible on a secondary monitor.



All is going very well exept 1 thing....


'Each update sends the following UDP packet :
Private Type OutGaugePacket
Time(0 To 3) As Byte 'time in milliseconds (to check order)
Car(0 To 3) As Byte 'Car name
Flags(0 To 1) As Byte 'Combination of OG_FLAGS, see below
Gear As Byte 'Reverse:0, Neutral:1, First:2...
SpareB As Byte 'Spare
Speed As Single 'M/S
Rpm As Single 'RPM
Turbo As Single 'BAR
EngTemp As Single 'C
Fuel As Single '0 to 1
OilPress As Single 'BAR
Spare1 As Single 'Spare
Spare2 As Single 'Spare
Spare3 As Single 'Spare
Throttle As Single '0 to 1
Brake As Single '0 to 1
Clutch As Single '0 to 1
Display1(0 To 15) As Byte 'Usually Fuel
Display2(0 To 15) As Byte 'Usually Settings
ID As Long '(optional ID - if specified in cfg.txt)
End Type

Private Const OG_SHIFTLIGHT As Long = 1
Private Const OG_FULLBEAM As Long = 2
Private Const OG_HANDBRAKE As Long = 4
Private Const OG_PITSPEED As Long = 8
Private Const OG_TC As Long = 16
Private Const OG_HEADLIGHTS As Long = 32
Private Const OG_SIGNAL_L As Long = 64
Private Const OG_SIGNAL_R As Long = 128
Private Const OG_REDLINE As Long = 256
Private Const OG_OILWARN As Long = 512
Private Const OG_1 As Long = 1024
Private Const OG_2 As Long = 2048
Private Const OG_3 As Long = 4096
Private Const OG_4 As Long = 8192
Private Const OG_KM As Long = 16384
Private Const OG_BAR As Long = 32768



How do I get the OG flags out of the FLAGS variable?

I want to copy the result into a new variable that would be 1 or 0

Anyone got an idea?

Kind Regards
Bjorn Pasteuning
edit: irrelevant.
I don't know VB but maybe you should try this
if Flags AND 256 = NOT 0 //og_redline is on

List of all bit values:
0000000000000000 = 0 None
1000000000000000 = 1 OG_SHIFTLIGHT
0100000000000000 = 2 OG_FULLBEAM
0010000000000000 = 4 OG_HANDBRAKE
0001000000000000 = 8 OG_PITSPEED
0000100000000000 = 16 OG_TC
0000010000000000 = 32 OG_HEADLIGHTS
0000001000000000 = 64 OG_SIGNAL_L
0000000100000000 = 128 OG_SIGNAL_R
0000000010000000 = 256 OG_REDLINE
0000000001000000 = 512 OG_OILWARN
0000000000100000 = 1024 OG_1
0000000000010000 = 2048 OG_2
0000000000001000 = 4096 OG_3
0000000000000100 = 8192 OG_4
0000000000000010 = 16384 OG_KM
0000000000000001 = 32786 OG_BAR

Shift light is active, driver is in the redline.
1000000010000000 = 257 OG_SHIFTLIGHT & OG_REDLINE

In this case, the driver is revving the nuts off the engine.

Shift light is active, driver is in the redline and oil warning light is on.
1000000011000000 = 769 OG_SHIFTLIGHT & OG_REDLINE & OG_OILWARN

In this case the driver is revving the nuts off the engine and has done so for so long he heated up the oil so much that your now also throwing a warning light for oil temp too.

----

So now you have an idea on what it looks like to the computer. How do we now test for this situation? Well first, we have to know that we are reading this information from the flags part of the OutGauge Packet and now we test aginst each value for the state of the Flags part of the packet to see if that value is set in the Bit Field.

In PHP:

<?php 
if ($OutGaugePack->Flags OG_SHIFTLIGHT)
    
// Shift Light Is On;
if ($OutGaugePack->Flags OG_FULLBEAM)
    
// Full Beams Are On;
if ($OutGaugePack->Flags OG_HANDBRAKE)
    
// Hand Break is Active.
if ($OutGaugePack->Flags OG_PITSPEED)
    
// Pit speed Limit is On.
if ($OutGaugePack->Flags OG_TC)
    
// Traction Control is active.
if ($OutGaugePack->Flags OG_HEADLIGHTS)
    
// Headlights are On.
if ($OutGaugePack->Flags OG_SIGNAL_L)
    
// Left Turn Signal is Active.
if ($OutGaugePack->Flags OG_SIGNAL_R)
    
// Right Turn Signal is Active.
if ($OutGaugePack->Flags OG_REDLINE)
    
// Rev guage is on or above red line.
if ($OutGaugePack->Flags OG_OILWARN)
    
// Oil Warning Light is On.
if ($OutGaugePack->Flags OG_1)
    
// Not a clue.
if ($OutGaugePack->Flags OG_2)
    
// Not a clue.
if ($OutGaugePack->Flags OG_3)
    
// Not a clue.
if ($OutGaugePack->Flags OG_4)
    
// Not a clue.
if ($OutGaugePack->Flags OG_KM)
    
// Not a clue.
if ($OutGaugePack->Flags OG_BAR)
    
// Not a clue.
?>

Might be the same operator in VB. But, let me google that for yo ... BitFields in Visual Basic
Not sure what OG_1 - OG_4 are, but I believe OG_KM and OG_BAR are simply reporting what the LFS users settings are set to, rather Metric or Imperial, or PSI/BAR... at least that'd be my best understanding of it.
#6 - Silox
Well, if you don't know it, it's easy to test...

Just let LFS output all those variables, when you leave the pits for example...

I could do it, and put the info here, too bad I'm kinda busy now
Quote :'Shift Ligth
Select Case Packet.Flags And OG_SHIFTLIGHT
Case 0
ShiftLight = False
Case 1
ShiftLigth = True
End Select
picShiftLight.Visible = ShiftLigth

This is the code that I use for every Flag

How do you do this "digital" numbers? I want to make something like that, but I don't know how
-
(Silox) DELETED by Silox
I Attach my interface, I like you neddles how do you this triangle? Or better, do you know how to rotate an image? But first of this, how to load a image with transparent background.
Attached images
Sin título-1.jpg
Hi all!

Thanks for all your replies and help!

I have figured out howto..


If (Packet.Flags And OG_SHIFTLIGHT) > 0 Then
LEDShiftLigth.Visible = True
Else
LEDShiftLigth.Visible = False
End If

If (Packet.Flags And OG_FULLBEAM) > 0 Then
Headlights.Visible = True
Else
Headlights.Visible = False
End If

If (Packet.Flags And OG_SIGNAL_L) > 0 Then
LeftSignalLight.Visible = True
Else
LeftSignalLight.Visible = False
End If

If (Packet.Flags And OG_SIGNAL_R) > 0 Then
RightSignalLight.Visible = True
Else
RightSignalLight.Visible = False
End If

Works fantastic!
Optimization note.. If an if expression is true, don't assign a variable true.. just assign it the expression. Like so:


LEDShiftLigth.Visible = (Packet.Flags And OG_SHIFTLIGHT) > 0

Quote from Stuff :Optimization note.. If an if expression is true, don't assign a variable true.. just assign it the expression. Like so:


LEDShiftLigth.Visible = (Packet.Flags And OG_SHIFTLIGHT) > 0


Ok thanks for the tip!
Sorry....
Sorry for the gravedig..... but does anyone have a version of this that they would be willing to share with me, or just all the code i need to do the shift light?

Thanks in advance,

Kyle

FGED GREDG RDFGDR GSFDG