mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Merge remote-tracking branch 'origin/ls-arq' into ls-arq
This commit is contained in:
commit
250943f63f
6 changed files with 53 additions and 9 deletions
|
@ -1590,6 +1590,29 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
||||||
}
|
}
|
||||||
document.getElementById("bytes_per_min_compressed").innerHTML = arq_bytes_per_minute_compressed;
|
document.getElementById("bytes_per_min_compressed").innerHTML = arq_bytes_per_minute_compressed;
|
||||||
|
|
||||||
|
// SET TIME LEFT UNTIL FINIHED
|
||||||
|
if (typeof(arg.arq_seconds_until_finish) == 'undefined') {
|
||||||
|
var time_left = 0;
|
||||||
|
} else {
|
||||||
|
var arq_seconds_until_finish = arg.arq_seconds_until_finish
|
||||||
|
var hours = Math.floor(arq_seconds_until_finish / 3600);
|
||||||
|
var minutes = Math.floor((arq_seconds_until_finish % 3600) / 60 );
|
||||||
|
var seconds = arq_seconds_until_finish % 60;
|
||||||
|
|
||||||
|
if(hours < 0) {
|
||||||
|
hours = 0;
|
||||||
|
}
|
||||||
|
if(minutes < 0) {
|
||||||
|
minutes = 0;
|
||||||
|
}
|
||||||
|
if(seconds < 0) {
|
||||||
|
seconds = 0;
|
||||||
|
}
|
||||||
|
var time_left = "time left: ~ "+ minutes + "min" + " " + seconds + "s";
|
||||||
|
}
|
||||||
|
document.getElementById("transmission_timeleft").innerHTML = time_left;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// SET SPEED LEVEL
|
// SET SPEED LEVEL
|
||||||
|
|
||||||
|
@ -1611,6 +1634,7 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// SET TOTAL BYTES
|
// SET TOTAL BYTES
|
||||||
if (typeof(arg.total_bytes) == 'undefined') {
|
if (typeof(arg.total_bytes) == 'undefined') {
|
||||||
var total_bytes = 0;
|
var total_bytes = 0;
|
||||||
|
|
|
@ -221,6 +221,7 @@ client.on('data', function(socketdata) {
|
||||||
arq_rx_n_current_arq_frame: data['arq_rx_n_current_arq_frame'],
|
arq_rx_n_current_arq_frame: data['arq_rx_n_current_arq_frame'],
|
||||||
arq_n_arq_frames_per_data_frame: data['arq_n_arq_frames_per_data_frame'],
|
arq_n_arq_frames_per_data_frame: data['arq_n_arq_frames_per_data_frame'],
|
||||||
arq_bytes_per_minute: data['arq_bytes_per_minute'],
|
arq_bytes_per_minute: data['arq_bytes_per_minute'],
|
||||||
|
arq_seconds_until_finish: data['arq_seconds_until_finish'],
|
||||||
arq_compression_factor: data['arq_compression_factor'],
|
arq_compression_factor: data['arq_compression_factor'],
|
||||||
total_bytes: data['total_bytes'],
|
total_bytes: data['total_bytes'],
|
||||||
arq_transmission_percent: data['arq_transmission_percent'],
|
arq_transmission_percent: data['arq_transmission_percent'],
|
||||||
|
|
|
@ -1100,6 +1100,7 @@
|
||||||
<div class="progress" style="height: 30px;">
|
<div class="progress" style="height: 30px;">
|
||||||
<div class="progress-bar progress-bar-striped bg-primary" id="transmission_progress" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
<div class="progress-bar progress-bar-striped bg-primary" id="transmission_progress" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
<!--<p class="justify-content-center d-flex position-absolute w-100">PROGRESS</p>-->
|
<!--<p class="justify-content-center d-flex position-absolute w-100">PROGRESS</p>-->
|
||||||
|
<p class="justify-content-center mt-2 d-flex position-absolute w-100" id="transmission_timeleft">---</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -685,6 +685,11 @@ class DATA:
|
||||||
# static.RX_FRAME_BUFFER --> existing data
|
# static.RX_FRAME_BUFFER --> existing data
|
||||||
# temp_burst_buffer --> new data
|
# temp_burst_buffer --> new data
|
||||||
# search_area --> area where we want to search
|
# search_area --> area where we want to search
|
||||||
|
|
||||||
|
|
||||||
|
#data_mode = self.mode_list[self.speed_level]
|
||||||
|
#payload_per_frame = modem.get_bytes_per_frame(data_mode) - 2
|
||||||
|
#search_area = payload_per_frame - 3 # (3 bytes arq frame header)
|
||||||
search_area = 510 - 3 # (3 bytes arq frame header)
|
search_area = 510 - 3 # (3 bytes arq frame header)
|
||||||
|
|
||||||
search_position = len(static.RX_FRAME_BUFFER) - search_area
|
search_position = len(static.RX_FRAME_BUFFER) - search_area
|
||||||
|
@ -739,7 +744,7 @@ class DATA:
|
||||||
self.set_listening_modes(False, True, self.mode_list[self.speed_level])
|
self.set_listening_modes(False, True, self.mode_list[self.speed_level])
|
||||||
|
|
||||||
# Create and send ACK frame
|
# Create and send ACK frame
|
||||||
self.log.info("[TNC] ARQ | RX | SENDING ACK")
|
self.log.info("[TNC] ARQ | RX | SENDING ACK", finished=static.ARQ_SECONDS_UNTIL_FINISH, bytesperminute=static.ARQ_BYTES_PER_MINUTE)
|
||||||
self.send_burst_ack_frame(snr)
|
self.send_burst_ack_frame(snr)
|
||||||
|
|
||||||
# Reset n retries per burst counter
|
# Reset n retries per burst counter
|
||||||
|
@ -760,6 +765,7 @@ class DATA:
|
||||||
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
||||||
mycallsign=str(self.mycallsign, 'UTF-8'),
|
mycallsign=str(self.mycallsign, 'UTF-8'),
|
||||||
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
||||||
|
finished=static.ARQ_SECONDS_UNTIL_FINISH,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif rx_n_frame_of_burst == rx_n_frames_per_burst - 1:
|
elif rx_n_frame_of_burst == rx_n_frames_per_burst - 1:
|
||||||
|
@ -840,8 +846,10 @@ class DATA:
|
||||||
|
|
||||||
# transmittion duration
|
# transmittion duration
|
||||||
duration = time.time() - self.rx_start_of_transmission
|
duration = time.time() - self.rx_start_of_transmission
|
||||||
self.log.info("[TNC] ARQ | RX | DATA FRAME SUCCESSFULLY RECEIVED", nacks=self.frame_nack_counter,bytesperminute=static.ARQ_BYTES_PER_MINUTE, total_bytes=static.TOTAL_BYTES, duration=duration
|
self.calculate_transfer_rate_rx(
|
||||||
)
|
self.rx_start_of_transmission, len(static.RX_FRAME_BUFFER)
|
||||||
|
)
|
||||||
|
self.log.info("[TNC] ARQ | RX | DATA FRAME SUCCESSFULLY RECEIVED", nacks=self.frame_nack_counter,bytesperminute=static.ARQ_BYTES_PER_MINUTE, total_bytes=static.TOTAL_BYTES, duration=duration)
|
||||||
|
|
||||||
# Decompress the data frame
|
# Decompress the data frame
|
||||||
data_frame_decompressed = lzma.decompress(data_frame)
|
data_frame_decompressed = lzma.decompress(data_frame)
|
||||||
|
@ -973,11 +981,12 @@ class DATA:
|
||||||
overflows=static.BUFFER_OVERFLOW_COUNTER,
|
overflows=static.BUFFER_OVERFLOW_COUNTER,
|
||||||
nacks=self.frame_nack_counter,
|
nacks=self.frame_nack_counter,
|
||||||
duration=duration,
|
duration=duration,
|
||||||
bytesperminute=static.ARQ_BYTES_PER_MINUTE
|
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
||||||
|
data=data_frame,
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log.info("[TNC] ARQ | RX | Sending NACK")
|
self.log.info("[TNC] ARQ | RX | Sending NACK", finished=static.ARQ_SECONDS_UNTIL_FINISH, bytesperminute=static.ARQ_BYTES_PER_MINUTE)
|
||||||
self.send_burst_nack_frame(snr)
|
self.send_burst_nack_frame(snr)
|
||||||
|
|
||||||
# Update arq_session timestamp
|
# Update arq_session timestamp
|
||||||
|
@ -1018,6 +1027,7 @@ class DATA:
|
||||||
uuid=self.transmission_uuid,
|
uuid=self.transmission_uuid,
|
||||||
percent=static.ARQ_TRANSMISSION_PERCENT,
|
percent=static.ARQ_TRANSMISSION_PERCENT,
|
||||||
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
||||||
|
finished=static.ARQ_SECONDS_UNTIL_FINISH,
|
||||||
mycallsign=str(self.mycallsign, 'UTF-8'),
|
mycallsign=str(self.mycallsign, 'UTF-8'),
|
||||||
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
||||||
)
|
)
|
||||||
|
@ -1212,6 +1222,7 @@ class DATA:
|
||||||
uuid=self.transmission_uuid,
|
uuid=self.transmission_uuid,
|
||||||
percent=static.ARQ_TRANSMISSION_PERCENT,
|
percent=static.ARQ_TRANSMISSION_PERCENT,
|
||||||
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
||||||
|
finished=static.ARQ_SECONDS_UNTIL_FINISH,
|
||||||
irs_snr=self.burst_ack_snr,
|
irs_snr=self.burst_ack_snr,
|
||||||
mycallsign=str(self.mycallsign, 'UTF-8'),
|
mycallsign=str(self.mycallsign, 'UTF-8'),
|
||||||
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
||||||
|
@ -1237,6 +1248,7 @@ class DATA:
|
||||||
uuid=self.transmission_uuid,
|
uuid=self.transmission_uuid,
|
||||||
percent=static.ARQ_TRANSMISSION_PERCENT,
|
percent=static.ARQ_TRANSMISSION_PERCENT,
|
||||||
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
bytesperminute=static.ARQ_BYTES_PER_MINUTE,
|
||||||
|
finished=static.ARQ_SECONDS_UNTIL_FINISH,
|
||||||
mycallsign=str(self.mycallsign, 'UTF-8'),
|
mycallsign=str(self.mycallsign, 'UTF-8'),
|
||||||
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
dxcallsign=str(self.dxcallsign, 'UTF-8'),
|
||||||
)
|
)
|
||||||
|
@ -1469,7 +1481,7 @@ class DATA:
|
||||||
)
|
)
|
||||||
|
|
||||||
# wait while timeout not reached and our busy state is busy
|
# wait while timeout not reached and our busy state is busy
|
||||||
channel_busy_timeout = time.time() + 30
|
channel_busy_timeout = time.time() + 15
|
||||||
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
|
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
|
||||||
threading.Event().wait(0.01)
|
threading.Event().wait(0.01)
|
||||||
|
|
||||||
|
@ -1963,7 +1975,7 @@ class DATA:
|
||||||
)
|
)
|
||||||
|
|
||||||
# wait while timeout not reached and our busy state is busy
|
# wait while timeout not reached and our busy state is busy
|
||||||
channel_busy_timeout = time.time() + 30
|
channel_busy_timeout = time.time() + 15
|
||||||
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
|
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
|
||||||
threading.Event().wait(0.01)
|
threading.Event().wait(0.01)
|
||||||
|
|
||||||
|
@ -2772,10 +2784,12 @@ class DATA:
|
||||||
static.ARQ_BYTES_PER_MINUTE = int(
|
static.ARQ_BYTES_PER_MINUTE = int(
|
||||||
receivedbytes / (transmissiontime / 60)
|
receivedbytes / (transmissiontime / 60)
|
||||||
)
|
)
|
||||||
|
static.ARQ_SECONDS_UNTIL_FINISH = int(((static.TOTAL_BYTES - receivedbytes) / (static.ARQ_BYTES_PER_MINUTE * static.ARQ_COMPRESSION_FACTOR)) * 60) -20 # offset because of frame ack/nack
|
||||||
|
|
||||||
else:
|
else:
|
||||||
static.ARQ_BITS_PER_SECOND = 0
|
static.ARQ_BITS_PER_SECOND = 0
|
||||||
static.ARQ_BYTES_PER_MINUTE = 0
|
static.ARQ_BYTES_PER_MINUTE = 0
|
||||||
|
static.ARQ_SECONDS_UNTIL_FINISH = 0
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.log.error(f"[TNC] calculate_transfer_rate_rx: Exception: {err}")
|
self.log.error(f"[TNC] calculate_transfer_rate_rx: Exception: {err}")
|
||||||
static.ARQ_TRANSMISSION_PERCENT = 0.0
|
static.ARQ_TRANSMISSION_PERCENT = 0.0
|
||||||
|
@ -2799,6 +2813,7 @@ class DATA:
|
||||||
static.ARQ_BITS_PER_SECOND = 0
|
static.ARQ_BITS_PER_SECOND = 0
|
||||||
static.ARQ_TRANSMISSION_PERCENT = 0
|
static.ARQ_TRANSMISSION_PERCENT = 0
|
||||||
static.TOTAL_BYTES = 0
|
static.TOTAL_BYTES = 0
|
||||||
|
static.ARQ_SECONDS_UNTIL_FINISH = 0
|
||||||
|
|
||||||
def calculate_transfer_rate_tx(
|
def calculate_transfer_rate_tx(
|
||||||
self, tx_start_of_transmission: float, sentbytes: int, tx_buffer_length: int
|
self, tx_start_of_transmission: float, sentbytes: int, tx_buffer_length: int
|
||||||
|
@ -2825,10 +2840,11 @@ class DATA:
|
||||||
if sentbytes > 0:
|
if sentbytes > 0:
|
||||||
static.ARQ_BITS_PER_SECOND = int((sentbytes * 8) / transmissiontime)
|
static.ARQ_BITS_PER_SECOND = int((sentbytes * 8) / transmissiontime)
|
||||||
static.ARQ_BYTES_PER_MINUTE = int(sentbytes / (transmissiontime / 60))
|
static.ARQ_BYTES_PER_MINUTE = int(sentbytes / (transmissiontime / 60))
|
||||||
|
static.ARQ_SECONDS_UNTIL_FINISH = int(((tx_buffer_length - sentbytes) / (static.ARQ_BYTES_PER_MINUTE* static.ARQ_COMPRESSION_FACTOR)) * 60 )
|
||||||
else:
|
else:
|
||||||
static.ARQ_BITS_PER_SECOND = 0
|
static.ARQ_BITS_PER_SECOND = 0
|
||||||
static.ARQ_BYTES_PER_MINUTE = 0
|
static.ARQ_BYTES_PER_MINUTE = 0
|
||||||
|
static.ARQ_SECONDS_UNTIL_FINISH = 0
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.log.error(f"[TNC] calculate_transfer_rate_tx: Exception: {err}")
|
self.log.error(f"[TNC] calculate_transfer_rate_tx: Exception: {err}")
|
||||||
|
|
|
@ -625,6 +625,7 @@ def send_tnc_state():
|
||||||
"rx_msg_buffer_length": str(len(static.RX_MSG_BUFFER)),
|
"rx_msg_buffer_length": str(len(static.RX_MSG_BUFFER)),
|
||||||
"arq_bytes_per_minute": str(static.ARQ_BYTES_PER_MINUTE),
|
"arq_bytes_per_minute": str(static.ARQ_BYTES_PER_MINUTE),
|
||||||
"arq_bytes_per_minute_burst": str(static.ARQ_BYTES_PER_MINUTE_BURST),
|
"arq_bytes_per_minute_burst": str(static.ARQ_BYTES_PER_MINUTE_BURST),
|
||||||
|
"arq_seconds_until_finish": str(static.ARQ_SECONDS_UNTIL_FINISH),
|
||||||
"arq_compression_factor": str(static.ARQ_COMPRESSION_FACTOR),
|
"arq_compression_factor": str(static.ARQ_COMPRESSION_FACTOR),
|
||||||
"arq_transmission_percent": str(static.ARQ_TRANSMISSION_PERCENT),
|
"arq_transmission_percent": str(static.ARQ_TRANSMISSION_PERCENT),
|
||||||
"total_bytes": str(static.TOTAL_BYTES),
|
"total_bytes": str(static.TOTAL_BYTES),
|
||||||
|
|
|
@ -101,6 +101,7 @@ ARQ_BITS_PER_SECOND_BURST: int = 0
|
||||||
ARQ_BITS_PER_SECOND: int = 0
|
ARQ_BITS_PER_SECOND: int = 0
|
||||||
ARQ_COMPRESSION_FACTOR: int = 0
|
ARQ_COMPRESSION_FACTOR: int = 0
|
||||||
ARQ_TRANSMISSION_PERCENT: int = 0
|
ARQ_TRANSMISSION_PERCENT: int = 0
|
||||||
|
ARQ_SECONDS_UNTIL_FINISH: int = 0
|
||||||
ARQ_SPEED_LEVEL: int = 0
|
ARQ_SPEED_LEVEL: int = 0
|
||||||
TOTAL_BYTES: int = 0
|
TOTAL_BYTES: int = 0
|
||||||
# set save to folder state for allowing downloading files to local file system
|
# set save to folder state for allowing downloading files to local file system
|
||||||
|
|
Loading…
Reference in a new issue