UUIDv7Lib provides version 7 UUID generation FB for Sysmac Studio. OMRON's Sysmac Studio is required to view and execute the code. For UUID, please refer to RFC 9562.
- Sysmac Studio Version 1.60
- NX102-9000 Ver 1.50 or higher compatible controller
git clone
this repository or download the zip.- Reference "UUIDv7Lib.slr" in your project.
Also check "UUIDv7LibExample.smc2".
git clone
this repository or download the zip.- Open "UUIDv7LibExample.smc2" in Sysmac Studio.
- Check "POU/Program/README".
- Build the project.
- Execute on simulator or actual machine.
"UUIDv7LibExample.smc2" includes "UUIDv7Lib.slr".
UIDv7Lib provides version 7 UUID generation FB, but please keep the following in mind.
-
Uses built-in Rand instruction for random number generation
An unseeded Rand instruction is used to generate random numbers, but the Rand instruction is most likely not a CSPRNG. It may be replaced with a random number generator using a hash function in the future. -
"rand_a" selects clock precision extension or counter
Default is counter. The clock accuracy is extended because NX allows task cycle settings in microseconds, and the DATA_AND_TIME type can also be specified in microseconds. The format is Q12 fixed-point number.
The following generates rand_a using a counter.
CASE iState OF
0:
iUUIDv7(Execute:=TRUE,
// Japan
UtcOffset:=TIME#+9h,
Timestamp:=DT#2024-12-12-21:59:59.005_000_000,
Out=>iUUID);
Inc(iState);
END_CASE;
The following generates rand_a using submicroseconds.
CASE iState OF
0:
iUUIDv7(Execute:=TRUE,
// Japan
UtcOffset:=TIME#+9h,
// Use the microsecond value in rand_a as a fixed-point number Q12.
UseExtClockPrecision:=TRUE,
// Use 456.7us for rand_a.
Timestamp:=DT#2024-12-12-21:59:59.005_456_700,
Out=>iUUID);
Inc(iState);
END_CASE;
I recommend checking the hash value of the acquired Sysmac Studio project.
file | sha256 |
---|---|
UUIDv7Lib.slr | 3f4c585fc45dea837f180c25b69d9685d670cca5ed741e41ad3434238ffedf78 |
UUIDv7LibExample.scm2 | 21c0104af32420945edf6c98b18367a73f5a7ab5390bef7e33606c5d653973d1 |