1 // native.cxx -- FGFS "Native" protocal class
3 // Written by Curtis Olson, started November 1999.
5 // Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include <simgear/debug/logstream.hxx>
32 #include <Main/globals.hxx>
33 #include <FDM/fdm_shell.hxx>
34 #include <FDM/flight.hxx>
36 FGNative::FGNative() {
39 FGNative::~FGNative() {
43 // open hailing frequencies
44 bool FGNative::open() {
46 SG_LOG( SG_IO, SG_ALERT, "This shouldn't happen, but the channel "
47 << "is already in use, ignoring" );
51 SGIOChannel *io = get_io_channel();
53 if ( ! io->open( get_direction() ) ) {
54 SG_LOG( SG_IO, SG_ALERT, "Error opening channel communication layer." );
63 // process work for this port
64 bool FGNative::process()
66 FDMShell* fdm = static_cast<FDMShell*>(globals->get_subsystem("flight"));
67 FGInterface* fdmState = fdm->getInterface();
72 SGIOChannel *io = get_io_channel();
73 if ( get_direction() == SG_IO_OUT ) {
74 return fdmState->writeState(io);
76 return fdmState->readState(io);
82 bool FGNative::close() {
83 SGIOChannel *io = get_io_channel();
87 if ( ! io->close() ) {