00001 #include "cableedit.h" 00002 #include "cable_NNI.h" 00003 #include "cable_NN.h" 00004 00005 ACable::ACable( CableNetNode * PNN ) : ANetNodeInstance( PNN ) { 00006 // default values 00007 Data.Device = "/dev/ttyS0"; 00008 Data.LockFile = "/var/Lock"; 00009 Data.Speed = 115200; 00010 Data.DataBits = 8; 00011 Data.Parity = 0; 00012 Data.StopBits = 1; 00013 Data.HardwareControl = 0; 00014 Data.SoftwareControl = 0; 00015 GUI = 0; 00016 RT = 0; 00017 } 00018 00019 void ACable::setSpecificAttribute( QString & A, QString & V) { 00020 if( A == "device" ) { 00021 Data.Device = V; 00022 } else if ( A == "lockfile" ) { 00023 Data.LockFile = V; 00024 } else if ( A == "speed" ) { 00025 Data.Speed = V.toLong(); 00026 } else if ( A == "parity" ) { 00027 Data.Parity = V.toShort(); 00028 } else if ( A == "databits" ) { 00029 Data.DataBits = V.toShort(); 00030 } else if ( A == "stopbits" ) { 00031 Data.StopBits = V.toShort(); 00032 } else if ( A == "hardwarecontrol" ) { 00033 Data.HardwareControl = ( V == "yes" ); 00034 } else if ( A == "softwarecontrol" ) { 00035 Data.SoftwareControl = ( V == "yes" ); 00036 } 00037 } 00038 00039 void ACable::saveSpecificAttribute( QTextStream & TS ) { 00040 TS << "device=" << quote( Data.Device ) << endl; 00041 TS << "lockfile=" << quote( Data.LockFile ) << endl; 00042 TS << "speed=" << Data.Speed << endl; 00043 TS << "parity=" << Data.Parity << endl; 00044 TS << "databits=" << Data.DataBits << endl; 00045 TS << "stopbits=" << Data.StopBits << endl; 00046 TS << "hardwarecontrol=" << 00047 ((Data.HardwareControl) ? "yes" : "no") << endl; 00048 TS << "softwarecontrol=" << 00049 ((Data.SoftwareControl) ? "yes" : "no") << endl; 00050 } 00051 00052 short ACable::generateFileEmbedded( SystemFile & SF, 00053 long DevNr ) { 00054 short rvl, rvd; 00055 00056 rvl = 1; 00057 if( SF.name() == "peers" ) { 00058 SF << Data.Device 00059 << endl; 00060 SF << Data.Speed 00061 << endl; 00062 SF << "lock " 00063 << Data.LockFile 00064 << endl; 00065 rvl = 0; 00066 } 00067 00068 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr ); 00069 return (rvd == 2 || rvl == 2 ) ? 2 : 00070 (rvd == 0 || rvl == 0 ) ? 0 : 1; 00071 } 00072 00073 QWidget * ACable::edit( QWidget * parent ) { 00074 GUI = new CableEdit( parent ); 00075 GUI->showData( Data ); 00076 return GUI; 00077 } 00078 00079 QString ACable::acceptable( void ) { 00080 return ( GUI ) ? GUI->acceptable( ) : QString(); 00081 } 00082 00083 void ACable::commit( void ) { 00084 if( GUI && GUI->commit( Data ) ) { 00085 setModified( 1 ); 00086 } 00087 }
1.4.2