Exit of we fail to connect

This commit is contained in:
Martin Karkowski 2021-07-30 07:49:48 +02:00
parent cb8e890ace
commit efaa3f4d38

View File

@ -2,7 +2,7 @@
* @author Martin Karkowski * @author Martin Karkowski
* @email m.karkowski@zema.de * @email m.karkowski@zema.de
* @create date 2020-03-02 11:37:50 * @create date 2020-03-02 11:37:50
* @modify date 2021-01-04 18:45:37 * @modify date 2021-07-30 07:49:17
* @desc [description] * @desc [description]
*/ */
@ -165,8 +165,8 @@ export class BeckhoffPlc extends BasePlcModule implements IPLCModule {
const _options = generateAdsOptions(options); const _options = generateAdsOptions(options);
this._logger.debug( this._logger.debug(
"Creating new ADS-Client " + "Creating new ADS-Client " +
_this.identifier + _this.identifier +
" with the following settings", " with the following settings",
JSON.stringify(_options) JSON.stringify(_options)
); );
@ -182,12 +182,10 @@ export class BeckhoffPlc extends BasePlcModule implements IPLCModule {
}); });
} }
} catch (err) { } catch (err) {
this._client.on("error", (err) => { this._logger.error(
this._logger.error( "Beckhoff Client " + _this.identifier + " got Error",
"Beckhoff Client " + _this.identifier + " got Error", err
err );
);
});
} }
}); });
@ -246,10 +244,10 @@ export class BeckhoffPlc extends BasePlcModule implements IPLCModule {
if (this._logger.enabledFor(Logger.DEBUG)) { if (this._logger.enabledFor(Logger.DEBUG)) {
_this._logger.debug( _this._logger.debug(
"updating io " + "updating io " +
name + name +
" to: \"" + " to: \"" +
handle.value.toString() + handle.value.toString() +
"\"" "\""
); );
} }
// Forward the content to the element. // Forward the content to the element.
@ -326,13 +324,16 @@ export class BeckhoffPlc extends BasePlcModule implements IPLCModule {
if (maxRetries > 0) { if (maxRetries > 0) {
this._logger.warn( this._logger.warn(
"Failed getting the Configuration. Retry left " + "Failed getting the Configuration. Retry left " +
maxRetries.toString() maxRetries.toString()
); );
this._logger.trace(err); this._logger.trace(err);
// Start a Time // Start a Time
setTimeout(_this._getConfig.apply, 1000, _this, maxRetries - 1); setTimeout(_this._getConfig.apply, 1000, _this, maxRetries - 1);
} else { } else {
this._logger.error("Failed getting the Configuration", err); this._logger.error("Failed getting the Configuration", err);
// Failed to connect to the PLC.
// Exit the System.
process.exit();
} }
}); });
} }
@ -472,15 +473,15 @@ export class BeckhoffPlc extends BasePlcModule implements IPLCModule {
// Log the Subscribe events // Log the Subscribe events
_this._logger.debug( _this._logger.debug(
(type === "output" ? "subscribing " : "publishing on ") + (type === "output" ? "subscribing " : "publishing on ") +
path path
); );
_this._logger.debug( _this._logger.debug(
"Setting \"" + "Setting \"" +
name + name +
"\" to \"" + "\" to \"" +
defaultValue.toString() + defaultValue.toString() +
"\"" "\""
); );
} }
@ -515,8 +516,8 @@ export class BeckhoffPlc extends BasePlcModule implements IPLCModule {
// Writing is not allowed, give a hint. // Writing is not allowed, give a hint.
_this._logger.debug( _this._logger.debug(
"client not updating \"" + "client not updating \"" +
handle.symname + handle.symname +
"\". System running without write access!" "\". System running without write access!"
); );
} }
} }