This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * Return millis since epoch in UTC | |
| * */ | |
| static long getUTCtimestamp(int day, int month, int year,int hour){ | |
| LocalDateTime ldt = LocalDateTime.of(year,month,day,hour,0); | |
| return ldt.atOffset(ZoneOffset.UTC).toInstant().toEpochMilli(); | |
| } | |
| /** | |
| * Get current zone as | |
| * */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| // Example on how to subscribe to a BVector and handle its events. | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| /** | |
| * Example of a BVector containing some setpoints/properies | |
| * | |
| * Add 3 BInteger properties to BVector | |
| * prio_1 | |
| * prio_2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum State { | |
| S1 { | |
| @Override | |
| State doSomething() { | |
| // Do something useful | |
| return S2; | |
| } | |
| }, | |
| S2 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static final int MAX_PW=9999; | |
| public static void main(String[] args) throws InterruptedException { | |
| /**Set a random pw for vault*/ | |
| Random rn = new Random(); | |
| Vault vault = new Vault(rn.nextInt(9999)); | |
| /**Start all threads*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| // Using default java.net package | |
| //////////////////////////////////////////////////////////////////////////////////////////////////// | |
| public class HttpGetSnippet { | |
| /** | |
| * Performs HTTP GET request. | |
| * | |
| * @param uri the URI of the connection | |
| * @return response object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Returns the maximum integer from the array using reduction. | |
| * @param arr the array of integers (not null) | |
| * @return the maximum element from the array | |
| */ | |
| public static int findMax(int[] arr) { | |
| return Arrays.stream(arr).reduce(Integer.MIN_VALUE, Integer::max); | |
| } | |
| public static double findMax(double[] arr) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 1. workbench -> tools -> new driver -> Ndriver | |
| * 2. After creating the driver, add a dependency if needed to "trafficDriver-rt.gradlle" (see page 394) | |
| */ | |
| /** | |
| * TdLinkMessage streams data to and from a byte array representation. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| example 1: | |
| The result of a "select" query is always a BITable. The items returned depend on the query. | |
| If the projection is omitted for a local query, the result is a collection of objects in the extent that matched the predicate requirements: | |
| */ | |
| BOrd ord = BOrd.make("slot:/foo/bar|bql:select * from control:NumericPoint"); | |
| BITable result = (BITable)ord.resolve(base).get(); | |
| TableCursor c = result.cursor(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //if you want to create a widget you create a java wrapper class to comminucate with the javascript and css script | |
| //this wrapper class will be an agent on the controller to add its functionality | |
| @NiagaraSingleton | |
| @NiagaraType ( | |
| agent = @AgentOn( | |
| types = {"devTrafficLights:TrafficLightController"} | |
| ) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * BSimpleJob provides base implementation for async operations | |
| * that require user visibillity. | |
| * For example: long running upload/download commands. | |
| **/ | |
| @NiagaraType | |
| public class BExampleJob extends BSimpleJob { |
NewerOlder