Skip to content

UUID Version 7 implements in Sysmac Studio.

License

Notifications You must be signed in to change notification settings

kmu2030/UUIDv7Lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UUIDv7Lib

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.

Environment

  • Sysmac Studio Version 1.60
  • NX102-9000 Ver 1.50 or higher compatible controller

How to use "UUIDv7Lib.slr"

  1. git clone this repository or download the zip.
  2. Reference "UUIDv7Lib.slr" in your project.

Also check "UUIDv7LibExample.smc2".

How to use "UUIDv7LibExample.smc2"

  1. git clone this repository or download the zip.
  2. Open "UUIDv7LibExample.smc2" in Sysmac Studio.
  3. Check "POU/Program/README".
  4. Build the project.
  5. Execute on simulator or actual machine.

"UUIDv7LibExample.smc2" includes "UUIDv7Lib.slr".

Explanation

UIDv7Lib provides version 7 UUID generation FB, but please keep the following in mind.

  1. 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.

  2. "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.

Generating UUID using counters

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;

Generating UUIDs using clock precision extensions

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;

File hash

I recommend checking the hash value of the acquired Sysmac Studio project.

file sha256
UUIDv7Lib.slr 3f4c585fc45dea837f180c25b69d9685d670cca5ed741e41ad3434238ffedf78
UUIDv7LibExample.scm2 21c0104af32420945edf6c98b18367a73f5a7ab5390bef7e33606c5d653973d1

Releases

No releases published