43const double K = 1.38 * 1.E-23;
44const double q = 1.6 * 1.E-19;
50 : TclClass(
"Module/UW/OPTICAL/PHY")
62 , lut_token_separator_(
'\t')
64 , variable_temperature_(false)
66 if (!MPhy_Bpsk::initialized) {
69 MPhy_Bpsk::initialized =
true;
84 if (strcasecmp(argv[1],
"useLUT") == 0) {
87 }
else if (strcasecmp(argv[1],
"useWOSS") == 0) {
91 }
else if (strcasecmp(argv[1],
"setVariableTemperature") == 0) {
95 }
else if (argc == 3) {
96 if (strcasecmp(argv[1],
"setLUTFileName") == 0) {
97 string tmp_ = ((
char *) argv[2]);
98 if (tmp_.size() == 0) {
99 fprintf(stderr,
"Empty string for the file name");
104 }
else if (strcasecmp(argv[1],
"setLUTSeparator") == 0) {
105 string tmp_ = ((
char *) argv[2]);
106 if (tmp_.size() == 0) {
107 fprintf(stderr,
"Empty char for the file name");
114 return MPhy_Bpsk::command(argc, argv);
120 hdr_MPhy *ph = HDR_MPHY(p);
121 if ((PktRx == 0) && (txPending ==
false)) {
123 if (snr_dB > MPhy_Bpsk::getAcquisitionThreshold()) {
124 if (ph->modulationType == MPhy_Bpsk::modid) {
130 cout <<
"UwOpticalPhy::Drop Packet::Wrong modulation"
135 cout <<
"UwOpticalPhy::Drop Packet::Below Threshold : snrdb = "
137 <<
", threshold = " << MPhy_Bpsk::getAcquisitionThreshold()
142 cout <<
"UwOpticalPhy::Drop Packet::Synced onto another packet "
144 << PktRx <<
", pending = " << txPending << endl;
151 hdr_MPhy *ph = HDR_MPHY(p);
152 double snr_linear = pow((
S * ph->Pr), 2) / ph->Pn;
153 return snr_linear ? 10 * log10(snr_linear) : -DBL_MAX;
159 hdr_MPhy *ph = HDR_MPHY(p);
160 Position *dest = ph->dstPosition;
162 double depth =
use_woss_ ? -dest->getAltitude() : -dest->getZ();
169 hdr_MPhy *ph = HDR_MPHY(p);
170 Position *dest = ph->dstPosition;
172 double depth =
use_woss_ ? -dest->getAltitude() : -dest->getZ();
177 double circuit_noise = 2 *
q * (
Id + il) * ph->srcSpectralMask->getBandwidth() +
178 (4 *
K * t * ph->srcSpectralMask->getBandwidth()) /
R;
179 return circuit_noise + pow(lut_value *
Ar_ *
S, 2);
187 hdr_cmn *ch = HDR_CMN(p);
188 if (MPhy_Bpsk::PktRx != 0) {
189 if (MPhy_Bpsk::PktRx == p) {
191 double interference_power =
192 interference_->getInterferencePower(p);
193 if (interference_power == 0) {
200 cout <<
"UwOpticalPhy::endRx interference power = "
201 << interference_power << endl;
222 DepthMap::iterator it =
lut_map.lower_bound(depth);
223 if (it !=
lut_map.end() && it->first == depth) {
225 std::cout << depth <<
" " << it->first <<
" " << it->second
231 std::cout << depth <<
" Nothing returned depth = " << depth
236 DepthMap::iterator u_it = it;
239 std::cout << depth <<
" " << it->first <<
" " << it->second <<
" "
240 << u_it->first <<
" " << u_it->second << std::endl;
242 depth, it->first, it->second, u_it->first, u_it->second);
247 double x,
double x1,
double y1,
double x2,
double y2)
250 double m = (y1 - y2) / (x1 - x2);
251 double q = y1 - m * x1;
258 ifstream input_file_;
261 if (input_file_.is_open()) {
263 for (
int i = 0; i < 2; ++i) {
264 std::getline(input_file_, line_);
268 while (std::getline(input_file_, line_)) {
269 ::std::stringstream line_stream(line_);
Class used to represents the UWOPTICAL_MPROPAGATION.
TclObject * create(int, const char *const *)
virtual void initializeLUT()
Inizialize LUT of c_variable values.
virtual double lookUpLightNoiseE(double depth)
DepthMap lut_map
Lookup table map of the solar noise versus the depth.
bool variable_temperature_
Flag to set whether the temperature is costant or varialbe with the depth.
virtual void startRx(Packet *p)
virtual double getNoisePower(Packet *p)
virtual void endRx(Packet *p)
char lut_token_separator_
double getVarTemperature(Packet *p)
virtual double getSNRdB(Packet *p)
bool use_woss_
Flag to set whether woss is employed.
UwOpticalPhy()
Constructor of UwMultiPhy class.
virtual int command(int, const char *const *)
TCL command interpreter.
virtual double linearInterpolator(double x, double x1, double y1, double x2, double y2)
Definition of UwOpticalMPropagation class.
#define NOT_VARIABLE_TEMPERATURE
UwOpticalPhyClass class_module_optical
Definition of UwOptical class.
#define OPTICAL_MODULATION_TYPE