Open Akeold opened 5 years ago
@Akeold @Jozo132 same question ? How should I set an internal boolean variable (I/O Channel) address on FINS read node?
I have to read the address 4000.00 which is an internal boolean variable (I/O Channel). How should I set this address on FINS read node?
Hello, sorry for my late reply. Right now the only way to extract boolean values from addresses is to add a function block
const reverseString = str => (str === '') ? '' : reverseString(str.substr(1)) + str.charAt(0); // Reverse string function
const numberToBits = value => reverseString(value.toString(2).padStart(16, '0')).split('').map(x => +x); // Number to Bit conversion
let targetAddress = msg.payload[0] // Use the first returned (address) value from OMRON Read block, for example '4000'
let targetBits = numberToBits(targetAddress) // Converted bit array
let target_00 = targetBits[0] // 4000.00 => 0 or 1
let target_01 = targetBits[1] // 4000.01 => 0 or 1
return {
payload: target_00 // return msg and do something with bit 4000.00
}
I have to read the address 4000.00 which is an internal boolean variable (I/O Channel). How should I set this address on FINS read node?