mrfioc2  2.3.0
Public Member Functions | List of all members
SFP Class Reference

#include <sfp.h>

Inheritance diagram for SFP:
Inheritance graph
[legend]
Collaboration diagram for SFP:
Collaboration graph
[legend]

Public Member Functions

 SFP (const std::string &n, volatile unsigned char *reg)
 
virtual ~SFP ()
 
virtual void lock () const
 
virtual void unlock () const
 
bool junk () const
 
void updateNow (bool=true)
 
double linkSpeed () const
 
double temperature () const
 
double powerTX () const
 
double powerRX () const
 
std::string vendorName () const
 
std::string vendorPart () const
 
std::string vendorRev () const
 
std::string serial () const
 
std::string manuDate () const
 
void report () const
 
- Public Member Functions inherited from mrf::ObjectInst< SFP >
virtual propertyBasegetPropertyBase (const char *pname, const std::type_info &ptype)
 
virtual void visitProperties (bool(*cb)(propertyBase *, void *), void *arg)
 
- Public Member Functions inherited from mrf::Object
const std::string & name () const
 
const Objectparent () const
 
child_iterator beginChild () const
 
child_iterator endChild () const
 
template<typename P >
mrf::auto_ptr< property< P > > getProperty (const char *pname)
 

Additional Inherited Members

- Public Types inherited from mrf::Object
typedef m_obj_children_t::const_iterator child_iterator
 
typedef std::map< std::string, std::string > create_args_t
 
typedef Object *(* create_factory_t) (const std::string &name, const std::string &klass, const create_args_t &args)
 
- Static Public Member Functions inherited from mrf::ObjectInst< SFP >
static int initObject ()
 
- Static Public Member Functions inherited from mrf::Object
static ObjectgetObject (const std::string &name)
 
static ObjectgetCreateObject (const std::string &name, const std::string &klass, const create_args_t &args=create_args_t())
 
static void addFactory (const std::string &klass, create_factory_t fn)
 
static void visitObjects (bool(*)(Object *, void *), void *)
 
- Protected Member Functions inherited from mrf::ObjectInst< SFP >
 ObjectInst (const std::string &n)
 
 ObjectInst (const std::string &n, A a)
 
virtual ~ObjectInst ()
 
- Protected Member Functions inherited from mrf::Object
 Object (const std::string &n, const Object *par=0)
 
virtual ~Object ()=0
 

Detailed Description

Definition at line 16 of file sfp.h.

Constructor & Destructor Documentation

◆ SFP()

SFP::SFP ( const std::string &  n,
volatile unsigned char *  reg 
)

Definition at line 31 of file sfp.cpp.

33  ,base(reg)
34  ,buffer(SFPMEM_SIZE)
35  ,valid(false)
36 {
37  updateNow();
38 
39  /* Check for SFP with LC connector */
40  if(valid)
41  fprintf(stderr, "Found SFP EEPROM\n");
42  else
43  fprintf(stderr, "Found SFP Strangeness %02x%02x%02x%02x\n",
44  buffer[0],buffer[1],buffer[2],buffer[3]);
45 }
void updateNow(bool=true)
Definition: sfp.cpp:49
#define SFPMEM_SIZE
Definition: sfpinfo.h:4

◆ ~SFP()

SFP::~SFP ( )
virtual

Definition at line 47 of file sfp.cpp.

47 {}

Member Function Documentation

◆ junk()

bool SFP::junk ( ) const
inline

Definition at line 31 of file sfp.h.

31 {return 0;}

◆ linkSpeed()

double SFP::linkSpeed ( ) const

Definition at line 62 of file sfp.cpp.

63 {
64  if(!valid){
65  return -1;
66  }
67  return buffer[SFP_linkrate] * 100.0; // Gives MBits/s
68 }
#define SFP_linkrate
Definition: sfpinfo.h:22

◆ lock()

virtual void SFP::lock ( ) const
inlinevirtual

Implements mrf::Object.

Definition at line 28 of file sfp.h.

28 {guard.lock();};

◆ manuDate()

std::string SFP::manuDate ( ) const

Definition at line 128 of file sfp.cpp.

129 {
130  if(!valid)
131  return std::string(nomod);
132  std::string ret("20XX/XX");
133  ret[2]=buffer[SFP_man_date];
134  ret[3]=buffer[SFP_man_date+1];
135  ret[5]=buffer[SFP_man_date+2];
136  ret[6]=buffer[SFP_man_date+3];
137  return ret;
138 }
#define SFP_man_date
Definition: sfpinfo.h:31

◆ powerRX()

double SFP::powerRX ( ) const

Definition at line 86 of file sfp.cpp.

87 {
88  if(!valid){
89  return -1e-6;
90  }
91  return read16(SFP_rx_pwr) * 0.1e-6; // Gives Watts
92 }
#define SFP_rx_pwr
Definition: sfpinfo.h:36

◆ powerTX()

double SFP::powerTX ( ) const

Definition at line 78 of file sfp.cpp.

79 {
80  if(!valid){
81  return -1e-6;
82  }
83  return read16(SFP_tx_pwr) * 0.1e-6; // Gives Watts
84 }
#define SFP_tx_pwr
Definition: sfpinfo.h:35

◆ report()

void SFP::report ( ) const

Definition at line 140 of file sfp.cpp.

141 {
142  printf("SFP tranceiver information\n"
143  " Temp: %.1f C\n"
144  " Link: %.1f MBits/s\n"
145  " Tx Power: %.1f uW\n"
146  " Rx Power: %.1f uW\n",
147  temperature(),
148  linkSpeed(),
149  powerTX()*1e6,
150  powerRX()*1e6);
151  printf(" Vendor:%s\n Model: %s\n Rev: %s\n Manufacture date: %s\n Serial: %s\n",
152  vendorName().c_str(),
153  vendorPart().c_str(),
154  vendorRev().c_str(),
155  manuDate().c_str(),
156  serial().c_str());
157 }
double temperature() const
Definition: sfp.cpp:70
double linkSpeed() const
Definition: sfp.cpp:62
std::string vendorPart() const
Definition: sfp.cpp:104
std::string vendorName() const
Definition: sfp.cpp:96
std::string vendorRev() const
Definition: sfp.cpp:112
std::string manuDate() const
Definition: sfp.cpp:128
double powerTX() const
Definition: sfp.cpp:78
std::string serial() const
Definition: sfp.cpp:120
double powerRX() const
Definition: sfp.cpp:86

◆ serial()

std::string SFP::serial ( ) const

Definition at line 120 of file sfp.cpp.

121 {
122  if(!valid)
123  return std::string(nomod);
124  buffer_t::const_iterator it=buffer.begin()+SFP_serial;
125  return std::string(it, it+16);
126 }
#define SFP_serial
Definition: sfpinfo.h:27

◆ temperature()

double SFP::temperature ( ) const

Definition at line 70 of file sfp.cpp.

71 {
72  if(!valid){
73  return -40;
74  }
75  return read16(SFP_temp) / 256.0; // Gives degrees C
76 }
#define SFP_temp
Definition: sfpinfo.h:34

◆ unlock()

virtual void SFP::unlock ( ) const
inlinevirtual

Implements mrf::Object.

Definition at line 29 of file sfp.h.

29 {guard.unlock();};

◆ updateNow()

void SFP::updateNow ( bool  = true)

Definition at line 49 of file sfp.cpp.

50 {
51  /* read I/O 4 bytes at a time to preserve endianness
52  * for both PCI and VME
53  */
54  epicsUInt32* p32=(epicsUInt32*)&buffer[0];
55 
56  for(unsigned int i=0; i<SFPMEM_SIZE/4; i++)
57  p32[i] = be_ioread32(base+ i*4);
58 
59  valid = buffer[0]==3 && buffer[2]==7;
60 }
#define SFPMEM_SIZE
Definition: sfpinfo.h:4
#define be_ioread32(A)
Definition: mrfIoOpsDef.h:73

◆ vendorName()

std::string SFP::vendorName ( ) const

Definition at line 96 of file sfp.cpp.

97 {
98  if(!valid)
99  return std::string(nomod);
100  buffer_t::const_iterator it=buffer.begin()+SFP_vendor_name;
101  return std::string(it, it+16);
102 }
#define SFP_vendor_name
Definition: sfpinfo.h:25

◆ vendorPart()

std::string SFP::vendorPart ( ) const

Definition at line 104 of file sfp.cpp.

105 {
106  if(!valid)
107  return std::string(nomod);
108  buffer_t::const_iterator it=buffer.begin()+SFP_part_num;
109  return std::string(it, it+16);
110 }
#define SFP_part_num
Definition: sfpinfo.h:26

◆ vendorRev()

std::string SFP::vendorRev ( ) const

Definition at line 112 of file sfp.cpp.

113 {
114  if(!valid)
115  return std::string(nomod);
116  buffer_t::const_iterator it=buffer.begin()+SFP_part_rev;
117  return std::string(it, it+4);
118 }
#define SFP_part_rev
Definition: sfpinfo.h:30

The documentation for this class was generated from the following files: