<s> '''<STR_LIT>''' <EOL> import sys <EOL> import string <EOL> try : <EOL> from emanesh . events import EventService <EOL> except : <EOL> pass <EOL> from core . api import coreapi <EOL> from core . constants import * <EOL> from emane import Emane , EmaneModel <EOL> try : <EOL> import emaneeventservice <EOL> import emaneeventcommeffect <EOL> except Exception , e : <EOL> pass <EOL> class EmaneCommEffectModel ( EmaneModel ) : <EOL> def __init__ ( self , session , objid = None , verbose = False ) : <EOL> EmaneModel . __init__ ( self , session , objid , verbose ) <EOL> _name = "<STR_LIT>" <EOL> _confmatrix_shim_base = [ <EOL> ( "<STR_LIT>" , coreapi . CONF_DATA_TYPE_STRING , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( "<STR_LIT>" , coreapi . CONF_DATA_TYPE_UINT32 , '<STR_LIT:0>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( "<STR_LIT>" , coreapi . CONF_DATA_TYPE_BOOL , '<STR_LIT:0>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( "<STR_LIT>" , coreapi . CONF_DATA_TYPE_FLOAT , '<STR_LIT:1.0>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> _confmatrix_shim_081 = [ <EOL> ( "<STR_LIT>" , coreapi . CONF_DATA_TYPE_BOOL , '<STR_LIT:0>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( "<STR_LIT>" , coreapi . CONF_DATA_TYPE_BOOL , '<STR_LIT:0>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> _confmatrix_shim_091 = [ <EOL> ( "<STR_LIT>" , coreapi . CONF_DATA_TYPE_BOOL , '<STR_LIT:0>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> if Emane . version >= Emane . EMANE091 : <EOL> _confmatrix_shim = _confmatrix_shim_base + _confmatrix_shim_091 <EOL> else : <EOL> _confmatrix_shim = _confmatrix_shim_base + _confmatrix_shim_081 <EOL> _confmatrix = _confmatrix_shim <EOL> _confgroups = "<STR_LIT>" % len ( _confmatrix_shim ) <EOL> def buildnemxmlfiles ( self , e , ifc ) : <EOL> '''<STR_LIT>''' <EOL> values = e . getifcconfig ( self . objid , self . _name , <EOL> self . getdefaultvalues ( ) , ifc ) <EOL> if values is None : <EOL> return <EOL> shimdoc = e . xmldoc ( "<STR_LIT>" ) <EOL> shim = shimdoc . getElementsByTagName ( "<STR_LIT>" ) . pop ( ) <EOL> shim . setAttribute ( "<STR_LIT:name>" , "<STR_LIT>" ) <EOL> shim . setAttribute ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> names = self . getnames ( ) <EOL> shimnames = list ( names [ : len ( self . _confmatrix_shim ) ] ) <EOL> shimnames . remove ( "<STR_LIT>" ) <EOL> map ( lambda n : shim . appendChild ( e . xmlparam ( shimdoc , n , self . valueof ( n , values ) ) ) , shimnames ) <EOL> ff = self . valueof ( "<STR_LIT>" , values ) <EOL> if ff . strip ( ) != '<STR_LIT>' : <EOL> shim . appendChild ( e . xmlparam ( shimdoc , "<STR_LIT>" , ff ) ) <EOL> e . xmlwrite ( shimdoc , self . shimxmlname ( ifc ) ) <EOL> nemdoc = e . xmldoc ( "<STR_LIT>" ) <EOL> nem = nemdoc . getElementsByTagName ( "<STR_LIT>" ) . pop ( ) <EOL> nem . setAttribute ( "<STR_LIT:name>" , "<STR_LIT>" ) <EOL> nem . setAttribute ( "<STR_LIT:type>" , "<STR_LIT>" ) <EOL> e . appendtransporttonem ( nemdoc , nem , self . objid , ifc ) <EOL> nem . appendChild ( e . xmlshimdefinition ( nemdoc , self . shimxmlname ( ifc ) ) ) <EOL> e . xmlwrite ( nemdoc , self . nemxmlname ( ifc ) ) <EOL> def linkconfig ( self , netif , bw = None , delay = None , <EOL> loss = None , duplicate = None , jitter = None , netif2 = None ) : <EOL> '''<STR_LIT>''' <EOL> if self . session . emane . version >= self . session . emane . EMANE091 : <EOL> raise NotImplementedError , "<STR_LIT>" <EOL> def z ( x ) : <EOL> '''<STR_LIT>''' <EOL> if type ( x ) is str : <EOL> x = float ( x ) <EOL> if x is None : <EOL> return <NUM_LIT:0> <EOL> else : <EOL> return int ( x ) <EOL> service = self . session . emane . service <EOL> if service is None : <EOL> self . session . warn ( "<STR_LIT>" % self . _name ) <EOL> return <EOL> if netif is None or netif2 is None : <EOL> self . session . warn ( "<STR_LIT>" % self . _name ) <EOL> return <EOL> event = emaneeventcommeffect . EventCommEffect ( <NUM_LIT:1> ) <EOL> index = <NUM_LIT:0> <EOL> e = self . session . obj ( self . objid ) <EOL> nemid = e . getnemid ( netif ) <EOL> nemid2 = e . getnemid ( netif2 ) <EOL> mbw = bw <EOL> event . set ( index , nemid , <NUM_LIT:0> , z ( delay ) , <NUM_LIT:0> , z ( jitter ) , z ( loss ) , <EOL> z ( duplicate ) , long ( z ( bw ) ) , long ( z ( mbw ) ) ) <EOL> service . publish ( emaneeventcommeffect . EVENT_ID , <EOL> emaneeventservice . PLATFORMID_ANY , <EOL> nemid2 , emaneeventservice . COMPONENTID_ANY , <EOL> event . export ( ) ) </s>
