00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "l1394_toponode.h"
00019
00020
00021 using std::dec;
00022 using namespace std;
00023 namespace L1394{
00024 namespace internal{
00025 const char* TopoNode::port_value[] =
00026 {" Port not present", "Not active",
00027 "Active and connected to parent node",
00028 "Active and connected to child node" };
00029
00030
00031 const char* TopoNode::phy_speed_spec[] =
00032 {"98.304 Mbit/s", "196.608 Mbit/s",
00033 "393.216 Mbit/s", "<reserved>"};
00034
00035 const char* TopoNode::pwr_class_spec[] =
00036 {"Node does need bus power and does not repeat power.",
00037 "Self powered and provides 15W (minimum) to bus.",
00038 "Self powered and provides 30W (minimum) to bus.",
00039 "Self powered and provides 45W (minimum) to bus.",
00040 "Node need 3W from the bus.",
00041 "<reserved>",
00042 "Node need 3W from the bus. Additional 3W(max) is need to enable link.",
00043 "Node need 3W from the bus. Additional 7W(max) is need to enable link."};
00044
00045
00046
00047
00048 const char* TopoNode::phy_delay_spec[] =
00049 {"<=144ns (~14/Base_Rate)", "<reserved>", "<reserved>","<reserved>"};
00050
00051 TopoNode::TopoNode(int maxp,TopoNode *p)
00052 {
00053 parent = p;
00054
00055 max_port = maxp;
00056
00057 child = new TopoNode*[max_port];
00058 for (int i = 0; i<max_port; i++)
00059 child[i] = NULL ;
00060 port_status = new unsigned short int[max_port];
00061 }
00062
00063
00064 TopoNode::~TopoNode()
00065 {
00066 for (int i = 0; i < max_port; i++)
00067 delete child[i];
00068 delete[] port_status;
00069 }
00070
00071
00072
00073 void TopoNode::setPortStatus(int i, unsigned short int p)
00074 {
00075 if (i < max_port) port_status[i] = p;
00076 }
00077
00078
00079
00080 void TopoNode::printNode()
00081 {
00082 for (int i = 0; i < max_port; i++)
00083 {
00084 cout << "Actual node id : " << dec << getPhyId() << endl;
00085 cout << i << " th port : "<< port_value[port_status[i]] << " " << endl;
00086 }
00087 for (int j = 0; j < max_port; j++)
00088 if (getChild(j) != NULL) getChild(j)->printNode();
00089 cout << endl;
00090 }
00091
00092 void TopoNode::setNodeInfo(Quadlet *t)
00093 {
00094 node_info = *t;
00095 }
00096
00097 ostream& operator<<(ostream& o, TopoNode& n)
00098 {
00099 o << "Node Information: \n";
00100 o << " Speed : " << n.phy_speed_spec[n.getPhySpeed()] << '\n';
00101 o << " Delay : " << n.phy_delay_spec[n.getPhyDelay()] << '\n';
00102 o << " Power Class : " << n.pwr_class_spec[n.getPwrClass()] << endl;
00103 return o;
00104 }
00105 }
00106 }