00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <rtt/RTT.hpp>
00028
00029 #include "../drivers/lxrt/apci_lxrt.h"
00030
00031 #include <rtt/os/fosi.h>
00032 #include <rtt/Logger.hpp>
00033 #include "SwitchDigitalInapci1032.hpp"
00034
00035 namespace RTT
00036 {
00037
00038 SwitchDigitalInapci1032::SwitchDigitalInapci1032( const std::string& name ) :
00039 DigitalInInterface( name )
00040 {
00041 BoardHandle = bh;
00042 Logger::In in("SwitchDigitalInapci1032");
00043 log()<< name << ": BoardHandle is "<< bh <<endlog(Info);
00044 bh++;
00045
00046 }
00047
00048 SwitchDigitalInapci1032::~SwitchDigitalInapci1032()
00049 {
00050 closeBoardHandle();
00051 bh--;
00052 }
00053
00054 inline
00055 bool SwitchDigitalInapci1032::isOn( unsigned int bit) const
00056 {
00057 if ( bit >= 0 && bit < 32 )
00058 {
00059 unsigned long pb_ChannelValue;
00060 i_APCI1032_Read1DigitalInput( BoardHandle, bit, &pb_ChannelValue );
00061 return pb_ChannelValue == 1;
00062 }
00063 return false;
00064 }
00065
00066 bool SwitchDigitalInapci1032::isOff( unsigned int bit) const
00067 {
00068 return !isOn(bit);
00069 }
00070
00071
00072 bool SwitchDigitalInapci1032::readBit( unsigned int bit) const
00073 {
00074 return isOn(bit);
00075 }
00076
00077 unsigned int SwitchDigitalInapci1032::readSequence(unsigned int start_bit, unsigned int stop_bit) const
00078 {
00079 unsigned long pul_InputValue=0;
00080 i_APCI1032_Read32DigitalInput( BoardHandle, &pul_InputValue );
00081 return (pul_InputValue >> start_bit) & ( 1 << (stop_bit - start_bit + 1)) - 1;
00082 }
00083
00084 int SwitchDigitalInapci1032::checkAndGetPCISlotNumber()
00085 {
00086
00087
00088 return -1;
00089 }
00090
00091 int SwitchDigitalInapci1032::setBoardInformation()
00092 {
00093
00094 return -1;
00095 }
00096
00097 int SwitchDigitalInapci1032::getHardwareInformation( unsigned int * pui_BaseAddress, unsigned char * pb_InterruptNbr, unsigned char * pb_SlotNumber )
00098 {
00099
00100 return -1;
00101 }
00102
00103 int SwitchDigitalInapci1032::closeBoardHandle()
00104 {
00105
00106 return -1;
00107 }
00108
00109 int SwitchDigitalInapci1032::SwitchDigitalInapci1032::bh = 0;
00110 };
00111