Results 1 to 10 of 14
Thread: Help with FSbus C++ software
-
01-12-2010, 02:16 PM #1
- Join Date
- Jan 2007
- Location
- Netherlands
- Posts
- 201
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
-
01-12-2010, 04:26 PM #2
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
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
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;
Stefan
-
01-12-2010, 04:43 PM #3
- Join Date
- Jan 2007
- Location
- Netherlands
- Posts
- 201
-
01-12-2010, 04:47 PM #4
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Help with FSbus C++ software
Yes that is a Bit Input.
http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B
Look to Bitwise operators.
-
02-01-2010, 02:49 PM #5
- Join Date
- Jan 2007
- Location
- Netherlands
- Posts
- 201
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
-
02-01-2010, 03:17 PM #6
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
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??????????????
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); } } }
Stefan
-
02-02-2010, 02:16 PM #7
- Join Date
- Jan 2007
- Location
- Netherlands
- Posts
- 201
-
02-02-2010, 02:21 PM #8
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
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.
-
02-02-2010, 04:10 PM #9
- Join Date
- Jan 2007
- Location
- Netherlands
- Posts
- 201
-
02-02-2010, 05:35 PM #10
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
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 };
Similar Threads
-
FSBUS HELP
By mondo50m in forum General Builder Questions All Aircraft TypesReplies: 14Last Post: 10-31-2010, 03:53 PM -
Help with FSBUS DLL
By Anderson/SBSP in forum I/O Interfacing and HardwareReplies: 9Last Post: 08-19-2009, 02:49 AM -
Fsbus 2.4.3
By Anderson/SBSP in forum I/O Interfacing Hardware and SoftwareReplies: 9Last Post: 11-30-2008, 04:25 PM -
FSBUS IO PCB HELP please
By 388TH_A in forum I/O Interfacing Hardware and SoftwareReplies: 1Last Post: 11-23-2008, 01:19 AM -
Anyone got fsbus 2.2?
By mpl330 in forum I/O Interfacing Hardware and SoftwareReplies: 8Last Post: 04-18-2007, 10:04 AM
Womans in your city for night
JH startup on Client PC