Help with FSbus C++ software
Hi all,
I'm busy to transfer my old fsbus software to the latest version, but I need some help with it.
I'm using an offsets of the TSR software of Thomas Richter.
I want to write to offset 0x6DB7 bit 0 ( = below glide slope annunciator).
But what's the format, you write to a specific bit ?
I can't find it in the doc's provided.
Hope someone can help.
Best regards
Jan Geurtsen
Re: Help with FSbus C++ software
Hi,
yes that isnt in the Documentation. It is a part of C++.
You have to define the Offset that you are need and every single Bit.
A part of the .h file.
Code:
enum _OVERHEADIN {
CI_No_Smoking_on = (GROUP_OVERHEADIN * OBJECTS_PER_GROUP),
FS_LIGHT};
#define FS_LIGHT_NAV 0x01 //01
#define FS_LIGHT_Strobe 0x02 //02
With the 0x01 you assing bit 0.
0x01 = Bit0
0x02 = Bit1
0x04 = Bit2
0x08 = Bit3
0x10 = Bit4
0x20 = Bit5
0x40 = Bit6
0x80 = Bit7
Than you can use the bits in you code.
A Sample Part from my Cockpit.
Code:
case CI_SWITCH_Strobe_Stad:
if (val==0)
{
Light |= FS_LIGHT_NAV;
Light |= FS_LIGHT_Strobe;
//printf("Light On \n");
FsWrite (FS_LIGHT,Light);
}
else
{
Light &= ~FS_LIGHT_NAV;
Light &= ~FS_LIGHT_Strobe;
//printf("Light Off \n");
FsWrite (FS_LIGHT,Light);
}
break;
That is an input for one Light Switch.
Stefan
Re: Help with FSbus C++ software
Quote:
Originally Posted by
sgaert
Hi,
yes that isnt in the Documentation. It is a part of C++.
You have to define the Offset that you are need and every single Bit.
A part of the .h file.
Code:
enum _OVERHEADIN {
CI_No_Smoking_on = (GROUP_OVERHEADIN * OBJECTS_PER_GROUP),
FS_LIGHT};
#define FS_LIGHT_NAV 0x01 //01
#define FS_LIGHT_Strobe 0x02 //02
With the 0x01 you assing bit 0.
0x01 = Bit0
0x02 = Bit1
0x04 = Bit2
0x08 = Bit3
0x10 = Bit4
0x20 = Bit5
0x40 = Bit6
0x80 = Bit7
Than you can use the bits in you code.
A Sample Part from my Cockpit.
Code:
case CI_SWITCH_Strobe_Stad:
if (val==0)
{
Light |= FS_LIGHT_NAV;
Light |= FS_LIGHT_Strobe;
//printf("Light On \n");
FsWrite (FS_LIGHT,Light);
}
else
{
Light &= ~FS_LIGHT_NAV;
Light &= ~FS_LIGHT_Strobe;
//printf("Light Off \n");
FsWrite (FS_LIGHT,Light);
}
break;
That is an input for one Light Switch.
Stefan
Thanks Stefan,
I doesn't reconize it as a bit input.
Best regards
Jan Geurtsen
Re: Help with FSbus C++ software
Re: Help with FSbus C++ software
Hi
I've made some code (see below) which light my hardware Exec light of the Project magenta CDU.
Will this be work?
I'm not able to test it because I'm abroad.
It's using adress 0x052c bit 1 so I add the following to the .h file
#ifndef _TSR_H
#define _TSR_H
#define FS_CduExecLight 0x01 //01
void BuildTsrObjects();
void cbTsr (int oid, int val, double dval);
enum e_Tsr {
C_CduExecLight = (GROUP_TSR * OBJECTS_PER_GROUP),
};
#endif
And this to the .cpp file:
#include "stdafx.h"
#include "Tsr.h"
extern void TsrBuildObjects()
{
MkFsbusObject(BTP_D_OUT, C_CduExecLight,"OID",cbTsr,17,24);
MkFsObject(FS_CduExecLight, "OID", cbTsr, 0x052c,2, TP_I16, FS_NORMAL);
}
void cbTsr( int oid,int val,double dval)
{
switch(oid)
{
case FS_CduExecLight:
FsbusWrite (C_CduExecLight,val);
}
}
Best regards
Jan Geurtsen
Re: Help with FSbus C++ software
Hi Jan,
that is a realy hard question.
First yes it will work, BUT that is fortuity.
It only work i case of that you Value is in Bit0.
You dont readout the bit you read the Value in case on Bit0 it is both the same.
That always work as long you only need Bit0 if you like to use Bit1 or greater you need other code.
In my code a had make 1 funktion how switches all Lights. I was to lame to write always the same code for every output.
As first that is only for Outputs controlled by Bitīs. Im my case the max Number of Bits in a Offset is 8. It is possible to add more.
As First we need an array with all our Informations.
I use that Style FS_Objekt, Output_Bit0, Output_Bit1, Output_Bit2,.... and so on. Importend is that you have to fill every "line" of the array complet. I had made an C_non Output to an Output that you dont have connectet on your IO or DOut card.
That you have to write to the cpp file.
Code:
int LEDAusgabe[][9]={{FS_APAusgabe1,CO_APDisA,CO_APCmdA,CO_APCmdB,CO_APCwsA,CO_APCwsB,CO_APVS,CO_APALT,CO_APAPP},
{FS_APAusgabe2,CO_APLOC,CO_APLNav,CO_APVNav,CO_APFLCH,CO_APHDGHold,CO_APIAS,CO_APN1,CO_APAT},
{FS_OHLED1,CO_FUEL_PUMP_LEFT_FWD,CO_FUEL_PUMP_LEFT_AFT,CO_FUEL_PUMP_CENTRE_LEFT_LIGHT,CO_FUEL_PUMP_CENTRE_RIGHT_LIGHT,CO_FUEL_PUMP_RIGHT_FWD,CO_FUEL_PUMP_RIGHT_AFT,CO_DOORS_WING_L_AFT,CO_DOORS_WING_R_AFT}
};
int LEDMax =19; // how many lines have your array??????????????
Now there are all Objektbuild funktion.
After that comes the normal Eventfunktion withe the "old" switch call. BUT we dont need any switch.
Here is my complete funktion.
Code:
extern void LedausgabeEventHandler (int oid, int val, double dval)
{
int Led;
Led = val;
int arrayPostition=-1;
for(int i=0;i<LEDMax ;i++)
{
if(oid==LEDAusgabe[i][0])
arrayPostition=i;
}
if(arrayPostition!=-1)
{
for (int i=1;i<9;i++)
{
int x=(Led & 0x01);
FsbusWrite (LEDAusgabe[arrayPostition][i], x);
Led = (Led >> 1);
}
}
}
With that i Switch all my LED, btw. it takes 160ms to change all LED (300). That is so fast.
Stefan
Re: Help with FSbus C++ software
Quote:
Originally Posted by
sgaert
Hi Jan,
that is a realy hard question.
First yes it will work,
BUT that is fortuity.
It only work i case of that you Value is in Bit0.
You dont readout the bit you read the Value in case on Bit0 it is both the same.
That always work as long you only need Bit0 if you like to use Bit1 or greater you need other code.
In my code a had make 1 funktion how switches all Lights. I was to lame to write always the same code for every output.
As first that is only for Outputs controlled by Bitīs. Im my case the max Number of Bits in a Offset is 8. It is possible to add more.
As First we need an
array with all our Informations.
I use that Style FS_Objekt, Output_Bit0, Output_Bit1, Output_Bit2,.... and so on. Importend is that you have to fill every "line" of the array complet. I had made an C_non Output to an Output that you dont have connectet on your IO or DOut card.
That you have to write to the cpp file.
Code:
int LEDAusgabe[][9]={{FS_APAusgabe1,CO_APDisA,CO_APCmdA,CO_APCmdB,CO_APCwsA,CO_APCwsB,CO_APVS,CO_APALT,CO_APAPP},
{FS_APAusgabe2,CO_APLOC,CO_APLNav,CO_APVNav,CO_APFLCH,CO_APHDGHold,CO_APIAS,CO_APN1,CO_APAT},
{FS_OHLED1,CO_FUEL_PUMP_LEFT_FWD,CO_FUEL_PUMP_LEFT_AFT,CO_FUEL_PUMP_CENTRE_LEFT_LIGHT,CO_FUEL_PUMP_CENTRE_RIGHT_LIGHT,CO_FUEL_PUMP_RIGHT_FWD,CO_FUEL_PUMP_RIGHT_AFT,CO_DOORS_WING_L_AFT,CO_DOORS_WING_R_AFT}
};
int LEDMax =19; // how many lines have your array??????????????
Now there are all Objektbuild funktion.
After that comes the normal Eventfunktion withe the "old" switch call. BUT we dont need any switch.
Here is my complete funktion.
Code:
extern void LedausgabeEventHandler (int oid, int val, double dval)
{
int Led;
Led = val;
int arrayPostition=-1;
for(int i=0;i<LEDMax ;i++)
{
if(oid==LEDAusgabe[i][0])
arrayPostition=i;
}
if(arrayPostition!=-1)
{
for (int i=1;i<9;i++)
{
int x=(Led & 0x01);
FsbusWrite (LEDAusgabe[arrayPostition][i], x);
Led = (Led >> 1);
}
}
}
With that i Switch all my LED, btw. it takes 160ms to change all LED (300). That is so fast.
Stefan
Hi Stefan.
Have you declared i.e. CO_APDisA as offset 0x0000, bit x in the *.h file?
Best regards
Jan Geurtsen
Re: Help with FSbus C++ software
if you read bits you dont need to declare anything in the H file, you only need to build the enum.
Re: Help with FSbus C++ software
Quote:
Originally Posted by
sgaert
if you read bits you dont need to declare anything in the H file, you only need to build the enum.
Hi Stefan,
Thanks again for your great help.
Do you have a example piece of the enum code?
Best regards
Jan Geurtsen
Re: Help with FSbus C++ software
Code:
enum e_LEDOUT{
CO_APDisA = (GROUP_LEDOUT * OBJECTS_PER_GROUP),
CO_APCmdA,
CO_APCmdB,
CO_APCwsA,
CO_APCwsB,
CO_APVS,
CO_APALT,
CO_APAPP,
FS_APAusgabe1,
FS_APAusgabe2,
CO_APLOC,
CO_APLNav,
CO_APVNav,
CO_APFLCH,// and so on
};