Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcx committed Jul 12, 2017
1 parent 09b85ad commit 0dca481
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
6 changes: 5 additions & 1 deletion release_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
Usage is similar to the on-complete function. It fires on ADS-, XML- and
network errors.

- New feature: Timeout for XMLHttpRequest added. The default value is set to
5000 ms. You can change the value by overwriting the "xmlHttpReqTimeout"
property of the client.

- New feature: There are missing data types in some TwinCAT libraries. By
default TAME drops an error and stops importing the data types from the TPY
file. With the new client parameter "skipMissingTypes" set to true it will
just drop a message an continue parsing the file.




Expand Down
49 changes: 33 additions & 16 deletions tame-w-comments.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* TAME [TwinCAT ADS Made Easy] V4.1 170605
* TAME [TwinCAT ADS Made Easy] V4.1 170712
*
* Copyright (c) 2009-2017 Thomas Schmidt; t.schmidt.p1 at freenet.de
*
Expand All @@ -17,7 +17,7 @@
*/
var TAME = {
//Version
version:'V4.1 170605',
version:'V4.1 170712',
//Names of days and months. This is for the formatted output of date values. You can
//simply add your own values if you need.
weekdShortNames: {
Expand Down Expand Up @@ -264,6 +264,7 @@ TAME.WebServiceClient = function (service) {
service.skipMissingTypes = false;
}

//Cyclic ADS checks (experimental).
if (!isNaN(service.adsCheckInterval) && service.adsCheckInterval >= 1) {
log('TAME library info: Cyclic ADS state checks enabled. Interval time: ' + service.adsCheckInterval + ' ms.');

Expand Down Expand Up @@ -300,6 +301,9 @@ TAME.WebServiceClient = function (service) {
this.symTableReady = false;
this.dataTypeTableReady = false;
this.handleCacheReady = false;

//XMLHttpRequest timeout
this.xmlHttpReqTimeout = 5000;



Expand Down Expand Up @@ -947,9 +951,9 @@ TAME.WebServiceClient = function (service) {

//Test with timeout
//experimental, seems like it doesn't work with all browsers (05/2017)
this.xmlHttpReq.timeout = 5000;
this.xmlHttpReq.timeout = instance.xmlHttpReqTimeout;
this.xmlHttpReq.ontimeout = function(e) {
log('TAME library error: XMLHttpRequest timed out. Timeout 5 seconds.');
log('TAME library error: XMLHttpRequest timed out. Timeout ' + instance.xmlHttpReqTimeout + ' milliseconds.');
log(e);
if (typeof adsReq.reqDescr.ot === 'function') {
//on timeout function
Expand Down Expand Up @@ -3759,25 +3763,44 @@ TAME.WebServiceClient = function (service) {
};



/**
* This is the function for creating a sum read request.
* This is the function for reading the ADS state.
*
* @param {Object} reqDescr The Request Descriptor. Besides other information
* this object contains the allocation of PLC and
* JavaScript variables in an item list.
*/
this.readAdsState = function(reqDescr) {
//Generate the ADS request object and call the send function.
instance.adsState = null;
instance.adsStateTxt = '';
instance.deviceState = null;

var oefunct;

if (reqDescr === undefined) {
reqDescr = {};
} else if (typeof reqDescr.oe == 'function') {
//Save the original on-error function if exist.
oefunct = reqDescr.oe;
}

//On-error-function, reset the state
reqDescr.oe = function () {
log('TAME library error: ADS state request failed.');
instance.adsState = null;
instance.adsStateTxt = '';
instance.deviceState = null;

if (typeof oefunct == 'function') {
oefunct();
}
};

var adsReq = {
method: 'ReadState',
reqDescr: reqDescr
};
createRequest(adsReq).send();
};


/**
* Prints the cached handles to the console.
Expand Down Expand Up @@ -4818,13 +4841,7 @@ TAME.WebServiceClient = function (service) {
setInterval(instance.readAdsState, service.adsCheckInterval);
}
}

//----------------------------Test--------------------------------
//log('TAME library info: Reading the PLC state ...');
//instance.readAdsState({sync:true});
//log('TAME library info: Current PLC state: ' + instance.adsStateTxt);
//----------------------------Test--------------------------------



/**
* !!!!!INITIALIZATION OF THE SYMBOL TABLE!!!!!
Expand Down
4 changes: 2 additions & 2 deletions tame.js

Large diffs are not rendered by default.

0 comments on commit 0dca481

Please sign in to comment.