mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-06 05:24:01 -06:00
Implemented connection timeout in C++
This commit is contained in:
parent
4295d65115
commit
9ee6829ebc
5 changed files with 19 additions and 18 deletions
|
@ -301,12 +301,7 @@ sub connect {
|
|||
if (!$res) {
|
||||
$self->set_status("Connection failed");
|
||||
}
|
||||
{
|
||||
# set up a timeout
|
||||
my $timestamp = time();
|
||||
1 until $self->sender->is_connected || (time - $timestamp) >= CONNECTION_TIMEOUT;
|
||||
}
|
||||
if ($self->sender->is_connected) {
|
||||
if ($self->sender->wait_connected) {
|
||||
$self->set_status("Printer is online. You can now start printing from the queue on the right.");
|
||||
$self->status_timer->Start(STATUS_TIMER_INTERVAL, wxTIMER_CONTINUOUS);
|
||||
$self->temp_timer->Start(TEMP_TIMER_INTERVAL, wxTIMER_CONTINUOUS);
|
||||
|
|
|
@ -1094,16 +1094,7 @@ sub build {
|
|||
$self->{config}->serial_port,
|
||||
$self->{config}->serial_speed,
|
||||
);
|
||||
if ($res) {
|
||||
{
|
||||
# set up a timeout
|
||||
my $timestamp = time();
|
||||
my $CONNECTION_TIMEOUT = 3; # seconds
|
||||
1 until $sender->is_connected || (time - $timestamp) >= $CONNECTION_TIMEOUT;
|
||||
}
|
||||
$res = $sender->is_connected;
|
||||
}
|
||||
if ($res) {
|
||||
if ($res && $sender->wait_connected) {
|
||||
Slic3r::GUI::show_info($self, "Connection to printer works correctly.", "Success!");
|
||||
} else {
|
||||
Slic3r::GUI::show_error($self, "Connection failed.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue