www/js/global.js

Tue, 30 Apr 2024 17:26:41 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 30 Apr 2024 17:26:41 +0200
changeset 714
24749c296a50
parent 703
344470c6bb1c
permissions
-rw-r--r--

Version 0.9.19b2. Simulator redesign and it is now possible to run more then one simulator. All simulated devices have address names that include the simulator number. Added the setup screen for the most part. Not compatible with previous versions if a simulator was used, delete all simulators and simulated devices during stop and start.


var DeviceTypeData = [
 { id: 0, mno: 'NA', en: 'Unknown' },
 { id: 1, mno: 'W1', en: 'One-wire' },
 { id: 2, mno: 'GPIO', en: 'GPIO' },
 { id: 3, mno: 'RC433', en: 'RC-433' },
 { id: 4, mno: 'DHT', en: 'DHT11' },
 { id: 5, mno: 'I2C', en: 'I2C bus' },
 { id: 6, mno: 'SPI', en: 'SPI bus' },
 { id: 7, mno: 'SIM', en: 'Simulator' }
],
DeviceTypeSource = {
 localdata: DeviceTypeData,
 datatype: 'array',
 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
},
DeviceTypeAdapter = new $.jqx.dataAdapter(DeviceTypeSource),

DevicePresentData = [
 { id: 0, mno: 'UNDEF', en: 'Unknown' },
 { id: 1, mno: 'NO', en: 'No' },
 { id: 2, mno: 'YES', en: 'Yes' },
 { id: 3, mno: 'ERROR', en: 'Error' }
],
DevicePresentSource = {
 localdata: DevicePresentData,
 datatype: 'array',
 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
},
DevicePresentAdapter = new $.jqx.dataAdapter(DevicePresentSource),

DeviceDirectionData = [
 { id: 0, mno: 'UNDEF', en: 'Unknown' },
 { id: 1, mno: 'IN_BIN', en: 'Binary input' },
 { id: 2, mno: 'OUT_BIN', en: 'Binary output' },
 { id: 3, mno: 'IN_ANALOG', en: 'Analog input' },
 { id: 4, mno: 'OUT_ANALOG', en: 'Analog output' },
 { id: 5, mno: 'OUT_PWM', en: 'PWM output' },
 { id: 6, mno: 'INTERN', en: 'Intern' }
],
DeviceDirectionSource = {
 localdata: DeviceDirectionData,
 datatype: 'array',
 datafields: [{ name: 'id' }, { name: 'mno' }, { name: 'en' }]
},
DeviceDirectionAdapter = new $.jqx.dataAdapter(DeviceDirectionSource),

// Temp sensors droptdown list
tempsensorSource = {
 datatype: 'json',
 datafields: [
  { name: 'uuid', type: 'string' },
  { name: 'name', type: 'string' }
 ],
 url: 'drop_tempsensors.php'
},
tempsensorlist = new $.jqx.dataAdapter(tempsensorSource),

// Switches dropdown list
switchesSource = {
 datatype: 'json',
 datafields: [
  { name: 'uuid', type: 'string' },
  { name: 'name', type: 'string' }
 ],
 url: 'drop_switches.php'
},
switcheslist = new $.jqx.dataAdapter(switchesSource),

// Contacts dropdown list
contactsSource = {
 datatype: 'json',
 datafields: [
  { name: 'uuid', type: 'string' },
  { name: 'name', type: 'string' }
 ], 
 url: 'drop_contacts.php'
},
contactslist = new $.jqx.dataAdapter(contactsSource),


// options for editors

Show0dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 0 },
Show1dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 1 },
Show2dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 2 },
Show3dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 3 },
Show4dec = { inputMode: 'simple', theme: theme, width: 90, height: 23, readOnly: true, decimalDigits: 4 },
Spin0dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 0, spinButtons: true },
Spin1dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true },
Spin2dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true },
Spin3dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 3, spinButtons: true },
Spin4dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 4, spinButtons: true },
  PosInt = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 0, spinButtons: true },
  SubInt = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 63, decimalDigits: 0, spinButtons: true },
 GPIOInt = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: -1, max:31, decimalDigits: 0, spinButtons: true },
Perc1dec = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 100, decimalDigits: 1, spinButtons: true },
   Perc0 = { inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true };


/* Websocket interface. Place "websocket.onmessage = function(evt) {}" in the user script. */
var websocket = new ReconnectingWebSocket('ws://'+location.hostname+'/ws');

websocket.onerror = function(event) {
 console.log('Websocket error: ' + event.data);
}



$(document).ready(function() {

 $('#jqxMenu').jqxMenu({
  width: 1280,
  height: '30px',
  autoOpen: false,
  clickToOpen: true,
  theme: theme
 });
 $('#jqxWidget').css('visibility', 'visible');
});

mercurial