We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you've provided to them or that they've collected from your use of their services.

Complex functions

Below is the list of complex functions available in  jQuery.e-dom.2.0.js. Here is the link to the package with examples.

.MakeReadField()

.MakeWriteButton()

.MakeTapButton()

 

.MakeReadField(options)

Prepares the element to periodical refresh (initiated by StartRefreshing()) or single refresh (launched by .RefreshIt()).  Simplifies the handling of the data received from PLC.

 

Parameters:

  • read - address for reading given as a string
  • refresh –optional, default TRUE.  Decides if the element participates in the periodical refresh
  • refreshtype – optional, default ‘value’.  Decides the handling of the received data:

    value’ – data received from PLC are placed within the element (WARNING! All element’s content is overwriten) ,

    status’ – if the value recieved from the PLC differs from the element’s status (0 or 1), fires .FilpIt() function,

    slider’ – assumes that the given element is a slider (jQuery UI slider) and updates its value.
  • valuetype – optional, default ‘text’.  Active only for refreshtype=’value’.  Decides if the data received from the PLS should be written into the element without manipulation, or should be changed into temperature (valuetype=’temp’)
  • image – ooptional, Id of an image given as a sting.  Active for refreshtype=’status’.  Decides what image should be manipulated according to the data received from the PLC.

 

Example 1 (within $(window).load):

$('#ReadField1').MakeReadField({
	read: 'QX0.5'
});

After the StartRefreshing() is called, the data from QX0.5 address will be requested periodically and the response will be written into ‘Readfield1’,

Example2:

$('#ReadField2').MakeReadField({
	'IW0',
	valuetype: ‘temp’
});

After the StartRefreshing() is called, the data from IW0 will be requested periodically and the response will be converted into temperaturę (divided by 10, unit added) and written into ‘ReadFile2’.

Example 3:

$('#ReadField3').MakeReadField({
	read:'QX0.5',
	refreshtype: 'status',
	image: 'ReadField3_Image'
});

After the StartRefreshing() is called, the data from QX0.5 will be requested periodically and the response will be compared with the status of the ‘ReadField3’ element.  If status needs to be changed, the ‘flipped’ class will be added/removed and the ReadField3_Image will be changed.

 

.MakWriteButton(options)

Chanes the given element into a button, which when clicked sends the given data to the PLS.  After the data is sent it can optionally trigger a refresh of another element. 

 

Parameters:

  • write - address for writting given as a string
  • staticvalue – fixed value sent to the PLC, for example 30
  • dynamicvalue – id of an element holding the value to be sent.  The parameter is ignored if the 'staticvalue' is set.  The value can be stored in:

    an <div> element - the data is retreived with jQuery .text() function

    an <input> element - the data is retreived with jQuery .val() function

    an Slider (from jQuery UI), recognized by the ‘ui-slider’ class
  • refreshonwrite – optional, id of an element, which should be refreshed on successful write

 

Example 1 (within $(window).load):

$('#Button1').MakeWriteButton({
	write:'MB11',
	staticvalue: 1
});

After the Button1 is clicked, '1' is sent to the PLC to MB11 address.  Nothing else happens.

 

Example 2:

$('#Button2').MakeWriteButton({
	write: 'MB11',
	dynamicvalue: 'datafield1'
});

Afterh the Button2 is clicked, the value stored in 'datafield1' is sent to the PLC to MB11 address.  

$('#Button3').MakeWriteButton({
	write: 'MB11',
	staticvalue: 1,
	refreshonwrite: 'ButtonHolder'
});

After Button3 is clicked, '1' is sent to the PLC to MB11 address.  After a successful write the ‘ButtonHolder’ is refreshed

 

.MakeTapButton(options)

It is a combination of the .MakeReadField() and the .MakeWriteButton functions.

Changes the given element into a button, which when clicked sends 1 and 0 to the plc ('tap').  Additionally the given element will be periodically refreshed and its status will be updated.

Parameters:

  • write - address for writting given as a string
  • read – address for reading given as a stringg
  • refresh – optional, default TRUE.  Decides if the element should be periodically refreshed
  • image – optional.  Id of an image, which should be changed when the status is changed
  • tapduration – optional, default 0.  Decides how long the 'tap' should last, ie, with what delay the 0 is sent after the 1. Active only if the initial button status is 0.  Useful for controling the blinds with the function block from WAGO library.

 

Example 1 (within $(window).load):

$('#Button1').MakeTapButton({ 
	write: 'MB11',
	read: 'QX0.5'
});

Button1 will be a button, which 'taps' the variable under MB11 address and changing its status in line with the data received from QX0.5

$('#Button2').MakeTapButton({ 
	write: 'MB11',
	read: 'QX0.5',
	image: 'Button2_Image',
	tapduration: 1000
});

As in Example 1, but the tap, sent when the button's status is 0 will last over 1 sec.  The image with id ‘Button2_Image’ will be changed in line with the status of the button.