@HARMAN_Chris said:
Not natively, but like most things - you can code for that. We have used it in several proof of concept projects internally.
I have found the mqtt module in Harman training and it is usable. Can uuid4 be written with NS4 software? Written in Java format, the operation is unsuccessful. The long of NX is 32 bits, and the long of java is 64 bits, which requires bit operations.
I have found the mqtt module in Harman training and it is usable. Can uuid4 be written with NS4 software? Written in Java format, the operation is unsuccessful. The long of NX is 32 bits, and the long of java is 64 bits, which requires bit operations.
China can't go to YouTube
randomBytes[7] =randomBytes[7]&$0f; /* clear version */
randomBytes[7] =randomBytes[7]|$40; /* set to version 4 */
randomBytes[9] =randomBytes[9]&$3f; /* clear variant */
randomBytes[9] =randomBytes[9]|$80; /* set to IETF variant */
uuid(randomBytes)
I have found the mqtt module in Harman training and it is usable. Can uuid4 be written with NS4 software? Written in Java format, the operation is unsuccessful. The long of NX is 32 bits, and the long of java is 64 bits, which requires bit operations.
China can't go to YouTube
Does anyone know if this ever got an answer? I have exactly the same issue - I need a Netlinx equivalent of a 'long long' (64 bit integer) - NOT a double as I need to perform a bitwise operation on it. AFAIK using TYPE_CAST only works on 32 bit integers?
Comments
Not natively, but like most things - you can code for that. We have used it in several proof of concept projects internally.
https://youtu.be/ZOiR6ZQo2BE
I have found the mqtt module in Harman training and it is usable. Can uuid4 be written with NS4 software? Written in Java format, the operation is unsuccessful. The long of NX is 32 bits, and the long of java is 64 bits, which requires bit operations.
I have found the mqtt module in Harman training and it is usable. Can uuid4 be written with NS4 software? Written in Java format, the operation is unsuccessful. The long of NX is 32 bits, and the long of java is 64 bits, which requires bit operations.
China can't go to YouTube
NS
define_function randomUUID()
{~~~~
char ng
char randomBytes[16]
randomBytes[1]=random_number(255)
randomBytes[2]=random_number(255)
randomBytes[3]=random_number(255)
randomBytes[4]=random_number(255)
randomBytes[5]=random_number(255)
randomBytes[6]=random_number(255)
randomBytes[7]=random_number(255)
randomBytes[8]=random_number(255)
randomBytes[9]=random_number(255)
randomBytes[10]=random_number(255)
randomBytes[11]=random_number(255)
randomBytes[12]=random_number(255)
randomBytes[13]=random_number(255)
randomBytes[14]=random_number(255)
randomBytes[15]=random_number(255)
randomBytes[16]=random_number(255)
randomBytes[7] =randomBytes[7]&$0f; /* clear version */ randomBytes[7] =randomBytes[7]|$40; /* set to version 4 */ randomBytes[9] =randomBytes[9]&$3f; /* clear variant */ randomBytes[9] =randomBytes[9]|$80; /* set to IETF variant */ uuid(randomBytes)}
define_function UUID(Char fdata[16])
{
char i
// long msb;
// long lsb;
msb =0
lsb =0
for (i=1; i<=8; i++)
//为什么要&0xff?是因为要不能或上一个负数byte,char,short的&都是转换为int的
//因为long类型是64位,在进行|运算时,需要补全0才可以运算
msb = (msb << 8) | (fdata[i] & $ff);
for (i=9; i<=16; i++)
lsb = (lsb << 8) | (fdata[i] & $ff);
toString()
}
define_function toString()
{
sUUID="digits(msb >> 32, 8),'-',
digits(msb >> 16, 4),'-',
digits(msb, 4),'-',
digits(lsb >> 48, 4),'-',
digits(lsb, 12)";
}
define_function char[50] digits(long val, char len)
{
long hi
hi= 1 << (len * 4);
return itohex(hi | (val & (hi - 1)));
}
Java
private final long mostSigBits; // 高字节
private final long leastSigBits; // 低字节 private static class Holder { // 内部类 static final SecureRandom numberGenerator = new SecureRandom(); // 加密的强随机数生成器 } private UUID(byte[] data) { long msb = 0; long lsb = 0; assert data.length == 16 : "data must be 16 bytes in length"; for (int i=0; i<8; i++) msb = (msb << 8) | (data[i] & 0xff); // 使前八个字节依次向前移动8位,得到高字节 for (int i=8; i<16; i++) lsb = (lsb << 8) | (data[i] & 0xff); // 使后八个字节依次向前移动8位,得到低字节 this.mostSigBits = msb; this.leastSigBits = lsb; } public static UUID randomUUID() { SecureRandom ng = Holder.numberGenerator; byte[] randomBytes = new byte[16]; ng.nextBytes(randomBytes); // 为16位字节数组随机生成数值 randomBytes[6] &= 0x0f; /* clear version */ randomBytes[6] |= 0x40; /* set to version 4 */ randomBytes[8] &= 0x3f; /* clear variant */ randomBytes[8] |= 0x80; /* set to IETF variant */ return new UUID(randomBytes); } public String toString() { return (digits(mostSigBits >> 32, 8) + "-" + digits(mostSigBits >> 16, 4) + "-" + digits(mostSigBits, 4) + "-" + digits(leastSigBits >> 48, 4) + "-" + digits(leastSigBits, 12)); } /** Returns val represented by the specified number of hex digits. */ private static String digits(long val, int digits) { long hi = 1L << (digits * 4); return Long.toHexString(hi | (val & (hi - 1))).substring(1); }————————————————
some one can help me?
NetLinx DOUBLE is 64-bits
But
ERROR: E:\XIEYI\AMX Moudle\MQTT Code Examples\uuid\uuid.axs(75): C10584: Illegal type [DOUBLE] for a bitwise operation
Does anyone know if this ever got an answer? I have exactly the same issue - I need a Netlinx equivalent of a 'long long' (64 bit integer) - NOT a double as I need to perform a bitwise operation on it. AFAIK using TYPE_CAST only works on 32 bit integers?
Thanks
Simon
MQTT Client module is officially released.
All the info in the LinkedIn post
https://www.linkedin.com/posts/ian-craigie-1933a222_mqtt-paho-java-activity-6792519002011918336-at1v