From 4ccff4d311aee21848446ab04deddf0d61b269b8 Mon Sep 17 00:00:00 2001 From: Mathis-Hu Date: Mon, 28 Aug 2023 15:53:46 -0400 Subject: [PATCH 01/11] Complete rst formula documentation --- core/formula/doc/index.rst | 162 ++++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 4 deletions(-) diff --git a/core/formula/doc/index.rst b/core/formula/doc/index.rst index 892a3976df..91d797d244 100644 --- a/core/formula/doc/index.rst +++ b/core/formula/doc/index.rst @@ -1,12 +1,108 @@ Formulas ======== +Several types of formulas are supported. +A prefix of the form "=xx(..)" is typically used to select the formula. -Function categories -___________________ -*Arrays* +Operators +---- +You can use the following operators : +| **Arithmetic and maths operators :** +| " **+** " - Addition. +| " **-** " - Subtraction. +| " **\*** " - Multiplication. +| " **/** " - Division. +| " **^** " - Power. +| **rnd(x)** - Return a floating point number between 0 and x. +| **max(expression...)** - Return the maximum between all expressions. +| **min(expression...)** - Return the minimum between all expressions. + +| **Logical and comparison operators :** +| " **&** " / " **&&** " - AND. +| " **|** " / " **||** " - OR. +| " **!(...)** " - NOT. +| " **==** " - Equals. +| " **!==** " - Not equals. +| " **>=** " - Greater than or equal. +| " **>** " - Greater than. +| " **<=** " - Lesser than or equal. +| " **<** " - Lesser than. + +| **Conditional operator :** +| ** ? : ** - Return a first expression if condition is true or a second expression if it's false. + + +Maths +----- +**abs(double value)** - Returns the absolute value of a double value. + +**acos(double value)** - Returns the inverse cosine of a double value. The returned angle is in the +range 0.0 through pi. + +**asin(double value)** - Returns the inverse sine of a double value. The returned angle is in the +range -pi/2 through pi/2. + +**atan(double value)** - Returns the inverse tangent of a double value. the returned angle is in the +range -pi/2 through pi/2. + +**atan2(double y, double x)** - Returns the angle theta from the conversion of rectangular coordinates (x, y) +to polar coordinates (r, theta). This method computes the phase theta by computing an arc tangent +of y/x in the range of -pi to pi. + +**ceil(double value)** - Returns the smallest double value that is greater than or equal to the argument +and is equal to a mathematical integer. + +**cos(double value)** - Returns the trigonometric cosine of an angle. + +**cosh(double value)** - Returns the hyperbolic cosine of a double value. The hyperbolic cosine +of x is defined to be (e^x + e^-x)/2 where e is Euler's number. + +**exp(double value)** - Returns Euler's number e raised to the power of a double value. + +**expm1(double value)** - Returns (e^x) -1. Note that for values of x near 0, the exact sum of expm1(x) + 1 +is much closer to the true result of e^x than exp(x). + +**floor(double value)** - Returns the largest double value that is less than or equal to the +argument and is equal to a mathematical integer. + +**hypot(double x, double y)** - Returns hypotenuse : sqrt(x² +y²) without intermediate overflow or underflow. + +**log(double value)** - Returns the natural logarithm (base e) of a double value. + +**log10(double value)** - Returns the base 10 logarithm of a double value. + +**pow(double base, double exponent)** - Returns the value of the first argument raised +to the power of the second argument. + +**round(double value)** - Returns the closest long to the argument, with ties rounding to positive infinity. + +**sin(double value)** - Returns the trigonometric sine of an angle. + +**sinh(double value)** - Returns the hyperbolic sine of a double value. The hyperbolic sine +of x is defined to be (e^x - e^-x)/2 where e is Euler's number. + +**sqrt(double value)** - Returns the correctly rounded positive square root of a double value. + +**tan(double value)** - Returns the trigonometric tangent of an angle. + +**tanh(double value)** - Returns the hyperbolic tangent of a double value. The hyperbolic tangent +of x is defined to be (e^x - e^-x)/(e^x + e^-x), in other words, sinh(x)/cosh(x). +Note that the absolute value of the exact tanh is always less than 1. + +**toDegrees(double value)** - Converts an angle measured in radians to an approximately equivalent +angle measured in degrees. The conversion from radians to degrees is generally inexact; +users should not expect cos(toRadians(90.0)) to exactly equal 0.0. + +**toRadians(double value)** - Converts an angle measured in degrees to an approximately equivalent +angle measured in radians. The conversion from degrees to radians is generally inexact. + +**fac(double value)** - Calculate the factorial of the given number. + + +Arrays +------ **arrayDiv(VNumberArray array1, VNumberArray array2)** - Returns a VNumberarray where each element is defined as array1[x] / array2[x]. The input arrays must be of equal length. @@ -52,4 +148,62 @@ This includes the average, min, max, and element count **arrayMax(VNumberArray array)** - Returns a VDouble with the greatest value of the given array -**arrayMin(VNumberArray array)** - Returns a VDouble with the smallest value of the given array \ No newline at end of file +**arrayMin(VNumberArray array)** - Returns a VDouble with the smallest value of the given array + + +String +------ +**concat(String s...)** - Concatenate a list of strings of a string array. + +**strEqual(String s1, String s2)** - Compare value of 2 strings. Return true if s1 equals s2, else false. + + +Enum +---- +**enumOf(VNumber value, VNumberArray intervals, VStringArray labels)** - Creates a VEnum based a value and a set of intervals. + +**indexOf(Enum e)** - Return the index of the enum value. + + +Alarm +----- +**highestSeverity(String s...)** - Returns the highest severity. + +**majorAlarm(Boolean condition, String s)** - Returns a string with major severity when the given condition is true. + +**minorAlarm(Boolean condition, String s)** - Returns a string with minor severity when the given condition is true. + + +Bitwise operation +----------------- +**bitAND(long a, long b)** - Bitwise AND, operation "a & b". Throw an exception if 'a' or 'b' are floating-point numbers. + +**bitOR(long a, long b)** - Bitwise OR, operation "a | b". Throw an exception if 'a' or 'b' are floating-point numbers. + +**bitXOR(long a, long b)** - Bitwise XOR, operation "a ^ b". Throw an exception if 'a' or 'b' are floating-point numbers. + +**bitLeftShift(long a, long b)** - Bitwise Left Shift, operation "a << b". Throw an exception if 'a' or 'b' are floating-point numbers. + +**bitRightShift(long a, long b)** - Bitwise Right Shift, operation "a >> b". Throw an exception if 'a' or 'b' are floating-point numbers. + +**bitNOT(long a)** - Bitwise NOT, operation "~a". Throw an exception if 'a' is a floating-point number. + + +Area detector +------------- +**adData(VNumberArray data, String type)** - Map the area detector data to the specified type, +i.e. [Int8, UInt8, Int16, UInt16, Int32, UInt32, Float32, Float64]. + +**imageHeight(VImage image)** - Fetch height of image. + +**imageWidth(VImage image)** - Fetch width of image. + +**imageValue(VImage image)** - Fetch array data of image. + +**imageXOffset(VImage image)** - Fetch horizontal offset of image. + +**imageXReversed(VImage image)** - Fetch horizontal reversal of image. + +**imageYOffset(VImage image)** - Fetch vertical offset of image. + +**imageYReversed(VImage image)** - Fetch vertical reversal of image. \ No newline at end of file From b25b7eac093a83b7994cf32dc3776c0a31ca4e2d Mon Sep 17 00:00:00 2001 From: Abigail Alexander Date: Wed, 30 Aug 2023 08:26:03 +0100 Subject: [PATCH 02/11] Update build.yml to not run on master --- .github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe534c954d..acb0378365 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,12 @@ name: Phoebus build -on: [push, pull_request] +on: + push: + branches-ignore: + - 'master' + pull_request: + branches-ignore: + - 'master' jobs: build: From eb5fbde52ae6cb7e0a87849c3e2f69f54c9cff83 Mon Sep 17 00:00:00 2001 From: Abraham Wolk Date: Wed, 30 Aug 2023 09:30:42 +0200 Subject: [PATCH 03/11] Add intended use cases of categories. --- app/display/editor/doc/widgets.rst | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/display/editor/doc/widgets.rst b/app/display/editor/doc/widgets.rst index 5605b88fd8..f62acfdb99 100644 --- a/app/display/editor/doc/widgets.rst +++ b/app/display/editor/doc/widgets.rst @@ -3,9 +3,38 @@ Widgets ======= The Display Builder application supports a set of widgets which can be used to create control GUIs. The widgets are -organized based on functionality as shown below +organized according to the categories *Graphics*, *Monitors*, *Controls*, *Plots*, *Structure*, and *Miscellaneous*: .. image:: images/widgets.png + :align: center + +Each category corresponds to an intended use case of the widgets belonging to the category: + +.. list-table:: + :widths: 30 70 + :header-rows: 1 + :align: center + + * - Widget Category + - Intended Use Case + + * - `Graphics` + - Static graphical elements + + * - `Monitors` + - Displaying values from PVs + + * - `Controls` + - Writing values to PVs + + * - `Plots` + - Plotting PV values + + * - `Structure` + - Grouping widgets and embedding displays + + * - `Miscellaneous` + - 3D Viewer, Web Browser .. toctree:: :maxdepth: 1 From b427281b19b34dd2942191f5a42c5ace260050c5 Mon Sep 17 00:00:00 2001 From: Mathis-Hu Date: Wed, 30 Aug 2023 12:07:46 -0400 Subject: [PATCH 04/11] Correct small mistakes in .rst --- app/alarm/datasource/doc/index.rst | 2 +- core/formula/doc/index.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/alarm/datasource/doc/index.rst b/app/alarm/datasource/doc/index.rst index 93f20185b8..710e087bd6 100644 --- a/app/alarm/datasource/doc/index.rst +++ b/app/alarm/datasource/doc/index.rst @@ -10,7 +10,7 @@ to take a set of actions needed to effectively handle an alarm. The alarm datasource provides a subsection of the alarm information and functionality. This makes it possible for user to access beast alarm information of any other cs-studio application. -OPI screens can now embed informatino about from the alarm server, like the acknowledgement state of a pv, etc.. +OPI screens can now embed information about from the alarm server, like the acknowledgement state of a pv, etc.. PV syntax --------- diff --git a/core/formula/doc/index.rst b/core/formula/doc/index.rst index 91d797d244..d0a83eea43 100644 --- a/core/formula/doc/index.rst +++ b/core/formula/doc/index.rst @@ -24,7 +24,7 @@ You can use the following operators : | " **|** " / " **||** " - OR. | " **!(...)** " - NOT. | " **==** " - Equals. -| " **!==** " - Not equals. +| " **!=** " - Not equals. | " **>=** " - Greater than or equal. | " **>** " - Greater than. | " **<=** " - Lesser than or equal. From 37e631d3d6798bdee541eb589499d7fda04cba96 Mon Sep 17 00:00:00 2001 From: Mathis-Hu Date: Wed, 30 Aug 2023 12:27:49 -0400 Subject: [PATCH 05/11] Add formulas & empty datasources example display. --- .../src/main/resources/examples/01_main.bob | 32 +- .../src/main/resources/examples/02_intro.bob | 2 +- .../main/resources/examples/10_scripts.bob | 2 +- .../resources/examples/11_datasources.bob | 13 + .../main/resources/examples/12_formulas.bob | 514 ++++++++++++++++++ .../src/main/resources/examples/encoding.bob | 2 +- .../resources/examples/misc_webbrowser.bob | 2 +- .../examples/monitors_bytemonitor.bob | 2 +- .../main/resources/examples/monitors_tank.bob | 2 +- .../main/resources/examples/plots_strip.bob | 2 +- .../src/main/resources/examples/probe.bob | 2 +- .../resources/examples/textupdate_format.bob | 2 +- .../main/resources/examples/use_classes.bob | 2 +- 13 files changed, 567 insertions(+), 12 deletions(-) create mode 100644 app/display/model/src/main/resources/examples/11_datasources.bob create mode 100644 app/display/model/src/main/resources/examples/12_formulas.bob diff --git a/app/display/model/src/main/resources/examples/01_main.bob b/app/display/model/src/main/resources/examples/01_main.bob index 261b9b052a..d7f1c00c5c 100644 --- a/app/display/model/src/main/resources/examples/01_main.bob +++ b/app/display/model/src/main/resources/examples/01_main.bob @@ -156,6 +156,34 @@ then press <SPACE> to activate button. 26 $(actions) + + Action Button_40 + + + 11_datasources.bob + replace + Datasources + + + 360 + 120 + 26 + $(actions) + + + Action Button_41 + + + 12_formulas.bob + replace + Formulas + + + 400 + 120 + 26 + $(actions) + Action Button_26 @@ -165,7 +193,7 @@ then press <SPACE> to activate button. Enablement - 360 + 440 120 26 $(actions) @@ -819,4 +847,4 @@ then press <SPACE> to activate button. 26 $(actions) - + \ No newline at end of file diff --git a/app/display/model/src/main/resources/examples/02_intro.bob b/app/display/model/src/main/resources/examples/02_intro.bob index fc6ea3dee5..16cd7ca338 100644 --- a/app/display/model/src/main/resources/examples/02_intro.bob +++ b/app/display/model/src/main/resources/examples/02_intro.bob @@ -1,6 +1,6 @@ - Display + Introduction -1 -1 diff --git a/app/display/model/src/main/resources/examples/10_scripts.bob b/app/display/model/src/main/resources/examples/10_scripts.bob index c8f656500c..f8a10ee2a1 100644 --- a/app/display/model/src/main/resources/examples/10_scripts.bob +++ b/app/display/model/src/main/resources/examples/10_scripts.bob @@ -1,6 +1,6 @@ - Display + Scripts 1150 2000 diff --git a/app/display/model/src/main/resources/examples/11_datasources.bob b/app/display/model/src/main/resources/examples/11_datasources.bob new file mode 100644 index 0000000000..f6548cf730 --- /dev/null +++ b/app/display/model/src/main/resources/examples/11_datasources.bob @@ -0,0 +1,13 @@ + + + Datasources + + Label_3 + Datasources + 210 + + + + + + diff --git a/app/display/model/src/main/resources/examples/12_formulas.bob b/app/display/model/src/main/resources/examples/12_formulas.bob new file mode 100644 index 0000000000..9b299912d8 --- /dev/null +++ b/app/display/model/src/main/resources/examples/12_formulas.bob @@ -0,0 +1,514 @@ + + + Formulas + 810 + 810 + + Label_3 + Formulas + + + + + + + Label_4 + Formulas are functions or operations that can sometimes be used instead of scripts or rules. + 41 + 381 + 50 + + + Label_5 + Typical usage : "=<name>(<arguments>)" + 120 + 340 + 30 + + + + + + + Label_7 + SECTION + Maths functions and operators : + 170 + 340 + 40 + + + + + + + + + true + + + Tank + =round(rnd(100)) + 'sim://flipflop' - 'sim://flipflop' + 20 + 220 + 50 + 271 + + + Label_9 + COMMENT + Display a rounded random double value between 0 and 100 + 80 + 330 + 220 + 49 + + + + + + + + + true + true + + + Text Update + =round(rnd(100)) + 'sim://flipflop' - 'sim://flipflop' + 90 + 270 + 110 + 40 + + + Text Update_1 + sim://ramp + 160 + 520 + 140 + 30 + false + + + LED (Multi State) + =abs('sim://ramp') + 20 + 520 + 120 + 120 + + + 0 + + + + + + + + 1 + + + + + + + + 2 + + + + + + + + 3 + + + + + + + + 4 + + + + + + + + 5 + + + + + + + + + + + + + + Label_10 + COMMENT + Return the absolute value of ramp sim PV + 160 + 560 + 140 + 49 + + + + + + + + + true + true + + + Label_11 + SECTION + Conditional and logical operators : + 381 + 80 + 340 + 40 + + + + + + + + + true + + + Text Update_2 + ='sim://flipflop' ? "True : 1" : "False : 0" + 410 + 110 + 70 + 40 + 1 + 1 + + + Picture + pic/and.png + 400 + 150 + 180 + 170 + 90.0 + + + Text Update_3 + ='sim://ramp' <= 0 ? "True : 1" : "False : 0" + 500 + 110 + 80 + 40 + 1 + 1 + + + Text Update_4 + =('sim://ramp' <= 0) && 'sim://flipflop' ? "True : 1" : "False : 0" + 450 + 320 + 80 + 40 + 1 + 1 + false + + + Label_12 + SECTION + Alarm functions : + 400 + 390 + 340 + 40 + + + + + + + + + true + + + Label_13 + COMMENT + Example of an AND gate + 560 + 210 + 140 + 49 + + + + + + + + + true + true + + + LED_1 + =('sim://ramp' <= 0) && 'sim://flipflop' + 460 + 200 + 60 + 50 + true + false + + + Text Update_5 + =majorAlarm((('sim://ramp' <= 0) && 'sim://flipflop'), "AND_alarm") + 410 + 430 + 120 + 30 + 1 + 1 + + + Label_14 + COMMENT + With the same example as above, return major alarm when true + 570 + 410 + 140 + 87 + + + + + + + + + true + true + + + Label_15 + SECTION + Enums functions : + 381 + 560 + 340 + 40 + + + + + + + + + true + + + Text Update_8 + =indexOf(highestSeverity('sim://ramp')) + 381 + 600 + 120 + 30 + 1 + 1 + + + Label_17 + COMMENT + Get the enum state number of the highest severity alarm from sim://ramp + 511 + 560 + 270 + 60 + + + + + + + + + true + true + + + Label_19 + COMMENT + 0 : No alarm + 550 + 600 + 140 + 17 + + + + + + + + + true + true + + + Label_21 + COMMENT + 1 : Minor alarm + 550 + 617 + 140 + 17 + + + + + + + + + true + true + + + Label_22 + COMMENT + 2 : Major alarm + 550 + 634 + 140 + 17 + + + + + + + + + true + true + + + Label_16 + COMMENT + Formulas : =round(rnd(100)) + 80 + 379 + 180 + 49 + + + + + + + + + true + true + + + Label_18 + COMMENT + Formula : =abs(<PV>) + 160 + 609 + 180 + 49 + + + + + + + + + true + true + + + Label_20 + COMMENT + Formulas : =<condition1> && <condition2> ? "True : 1" : "False : 0" + 560 + 259 + 180 + 121 + + + + + + + + + true + true + + + Label_23 + COMMENT + Formulas : =majorAlarm(<condition>, "AND_alarm") + 400 + 490 + 370 + 40 + + + + + + + + + true + true + + + Label_24 + COMMENT + Formulas : =indexOf(highestSeverity(<PV>)) + 370 + 670 + 409 + 29 + + + + + + + + + true + true + + + Label_25 + Formulas can be entered where you can enter PVs. + 80 + 381 + 50 + + diff --git a/app/display/model/src/main/resources/examples/encoding.bob b/app/display/model/src/main/resources/examples/encoding.bob index 4086f8160b..c315a41c8b 100644 --- a/app/display/model/src/main/resources/examples/encoding.bob +++ b/app/display/model/src/main/resources/examples/encoding.bob @@ -1,6 +1,6 @@ - Display + Encoding Label TITLE diff --git a/app/display/model/src/main/resources/examples/misc_webbrowser.bob b/app/display/model/src/main/resources/examples/misc_webbrowser.bob index b294825154..7ff0271294 100644 --- a/app/display/model/src/main/resources/examples/misc_webbrowser.bob +++ b/app/display/model/src/main/resources/examples/misc_webbrowser.bob @@ -1,6 +1,6 @@ - Display + Web Browser Label 20 diff --git a/app/display/model/src/main/resources/examples/monitors_bytemonitor.bob b/app/display/model/src/main/resources/examples/monitors_bytemonitor.bob index 02b6e36c0c..2af3884210 100644 --- a/app/display/model/src/main/resources/examples/monitors_bytemonitor.bob +++ b/app/display/model/src/main/resources/examples/monitors_bytemonitor.bob @@ -1,6 +1,6 @@ - Display + Byte Monitor Label Byte Monitor Widget diff --git a/app/display/model/src/main/resources/examples/monitors_tank.bob b/app/display/model/src/main/resources/examples/monitors_tank.bob index f6e136aa92..854fc8c647 100644 --- a/app/display/model/src/main/resources/examples/monitors_tank.bob +++ b/app/display/model/src/main/resources/examples/monitors_tank.bob @@ -1,6 +1,6 @@ - Display + Tank Text Update sim://sine(0, 100, 40, 0.1) diff --git a/app/display/model/src/main/resources/examples/plots_strip.bob b/app/display/model/src/main/resources/examples/plots_strip.bob index 89a361bd1f..e993279074 100644 --- a/app/display/model/src/main/resources/examples/plots_strip.bob +++ b/app/display/model/src/main/resources/examples/plots_strip.bob @@ -1,6 +1,6 @@ - Data Browser Plot + Strip Chart Plot 530 609 diff --git a/app/display/model/src/main/resources/examples/probe.bob b/app/display/model/src/main/resources/examples/probe.bob index 1feb57be93..2419b37ef9 100644 --- a/app/display/model/src/main/resources/examples/probe.bob +++ b/app/display/model/src/main/resources/examples/probe.bob @@ -1,6 +1,6 @@ - Display + Probe 580 Label diff --git a/app/display/model/src/main/resources/examples/textupdate_format.bob b/app/display/model/src/main/resources/examples/textupdate_format.bob index 88528e0327..54933d0910 100644 --- a/app/display/model/src/main/resources/examples/textupdate_format.bob +++ b/app/display/model/src/main/resources/examples/textupdate_format.bob @@ -1,6 +1,6 @@ - Display + Text Update Formatting DTL_LLRF:IOC1:Load diff --git a/app/display/model/src/main/resources/examples/use_classes.bob b/app/display/model/src/main/resources/examples/use_classes.bob index 0c4ddbecbb..6fb9d0204d 100644 --- a/app/display/model/src/main/resources/examples/use_classes.bob +++ b/app/display/model/src/main/resources/examples/use_classes.bob @@ -1,6 +1,6 @@ - Display + Classes Label TITLE From b6105f065d8948a9f38afadc5a078416f783bc45 Mon Sep 17 00:00:00 2001 From: Abigail Alexander Date: Thu, 31 Aug 2023 09:31:52 +0100 Subject: [PATCH 06/11] Update build.yml --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index acb0378365..59950d427b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,6 @@ on: branches-ignore: - 'master' pull_request: - branches-ignore: - - 'master' jobs: build: From 43f72f07317c6293ec3448fd3fea7afa658c70b0 Mon Sep 17 00:00:00 2001 From: Kunal Shroff Date: Thu, 31 Aug 2023 13:59:40 +0200 Subject: [PATCH 07/11] Add and explicit "saverestore" to REST URLs --- .../service/saveandrestore/web/controllers/BaseController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/BaseController.java b/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/BaseController.java index ff87d74339..3230b46029 100644 --- a/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/BaseController.java +++ b/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/BaseController.java @@ -23,6 +23,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.phoebus.service.saveandrestore.NodeNotFoundException; @@ -39,6 +40,8 @@ */ @RestController @SuppressWarnings("unused") + +@RequestMapping("SaveRestore") public abstract class BaseController { public static final String JSON = "application/json"; From 3f2a16ba7a756a56bb55d9f1d6bf5e89352b4528 Mon Sep 17 00:00:00 2001 From: Kunal Shroff Date: Thu, 31 Aug 2023 14:00:01 +0200 Subject: [PATCH 08/11] Add a landing page for Save and Restore service --- .../web/controllers/InfoController.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/InfoController.java diff --git a/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/InfoController.java b/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/InfoController.java new file mode 100644 index 0000000000..d040ddee61 --- /dev/null +++ b/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/InfoController.java @@ -0,0 +1,76 @@ +package org.phoebus.service.saveandrestore.web.controllers; + +import co.elastic.clients.elasticsearch.ElasticsearchClient; +import co.elastic.clients.elasticsearch._types.ElasticsearchVersionInfo; +import co.elastic.clients.elasticsearch.core.InfoResponse; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Controller implementing endpoints to retrieve service info + */ +@RestController +public class InfoController extends BaseController { + + private final Logger logger = Logger.getLogger(InfoController.class.getName()); + + @Value("${app.name:4.7.0}") + private String name; + + @Value("${app.version:4.7.0}") + private String version; + + @Autowired + @Qualifier("client") + ElasticsearchClient client; + + private static final ObjectMapper objectMapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT); + + /** + * + * @return Information about the Save and Restore service + */ + @GetMapping + public String info() { + + Map saveRestoreServiceInfo = new LinkedHashMap<>(); + saveRestoreServiceInfo.put("name", name); + saveRestoreServiceInfo.put("version", version); + + Map elasticInfo = new LinkedHashMap<>(); + try { + InfoResponse response = client.info(); + elasticInfo.put("status", "Connected"); + elasticInfo.put("clusterName", response.clusterName()); + elasticInfo.put("clusterUuid", response.clusterUuid()); + ElasticsearchVersionInfo version = response.version(); + elasticInfo.put("version", version.toString()); + //elasticInfo.put("elasticHost", host); + //elasticInfo.put("elasticPort", String.valueOf(port)); + } catch (IOException e) { + logger.log(Level.WARNING, "Failed to create Save and Restore service info resource.", e); + elasticInfo.put("status", "Failed to connect to elastic " + e.getLocalizedMessage()); + } + saveRestoreServiceInfo.put("elastic", elasticInfo); + + try { + return objectMapper.writeValueAsString(saveRestoreServiceInfo); + } catch (JsonProcessingException e) { + logger.log(Level.WARNING, "Failed to create Save and Restore service info resource.", e); + return "Failed to gather Save and Restore service info"; + } + } +} \ No newline at end of file From de17c4cb8d264e0babef09f8b3b6fc61d3f354c3 Mon Sep 17 00:00:00 2001 From: Kunal Shroff Date: Thu, 31 Aug 2023 14:46:24 +0200 Subject: [PATCH 09/11] Using the application.properties to define the context --- .../service/saveandrestore/web/controllers/BaseController.java | 2 -- .../save-and-restore/src/main/resources/application.properties | 2 ++ .../src/test/resources/test_application.properties | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/BaseController.java b/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/BaseController.java index 3230b46029..e49fe8a961 100644 --- a/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/BaseController.java +++ b/services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/web/controllers/BaseController.java @@ -40,8 +40,6 @@ */ @RestController @SuppressWarnings("unused") - -@RequestMapping("SaveRestore") public abstract class BaseController { public static final String JSON = "application/json"; diff --git a/services/save-and-restore/src/main/resources/application.properties b/services/save-and-restore/src/main/resources/application.properties index 8b483393a7..21b73e56c6 100644 --- a/services/save-and-restore/src/main/resources/application.properties +++ b/services/save-and-restore/src/main/resources/application.properties @@ -12,6 +12,8 @@ elasticsearch.http.port=9200 # Do not change this! spring.jackson.serialization.write-dates-as-timestamps=false +server.servlet.contextPath=/save-restore + # The names of the index to use for save&restore elasticsearch.tree_node.index=saveandrestore_tree elasticsearch.configuration_node.index=saveandrestore_configuration diff --git a/services/save-and-restore/src/test/resources/test_application.properties b/services/save-and-restore/src/test/resources/test_application.properties index 8cddd387d4..922d3c9eb9 100644 --- a/services/save-and-restore/src/test/resources/test_application.properties +++ b/services/save-and-restore/src/test/resources/test_application.properties @@ -2,6 +2,8 @@ logging.level.org.springframework=INFO app.version=@project.version@ app.name=@project.name@ +server.servlet.contextPath=/save-restore + # Elasticsearch connection parameters elasticsearch.network.host=localhost elasticsearch.http.port=9200 From 64f1ae61ee8fabe61038b8ee8e88c2509437d1e8 Mon Sep 17 00:00:00 2001 From: Kunal Shroff Date: Thu, 31 Aug 2023 16:09:06 +0200 Subject: [PATCH 10/11] updating preferences to match new save-restore URL's --- .../service/src/main/resources/client_preferences.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/save-and-restore/service/src/main/resources/client_preferences.properties b/app/save-and-restore/service/src/main/resources/client_preferences.properties index d4e2510154..8e58e2b1b5 100644 --- a/app/save-and-restore/service/src/main/resources/client_preferences.properties +++ b/app/save-and-restore/service/src/main/resources/client_preferences.properties @@ -21,7 +21,7 @@ # ----------------------------------------------- # The URL to the save-and-restore service -jmasar.service.url=http://localhost:8080 +jmasar.service.url=http://localhost:8080/save-restore # Read timeout (in ms) used by the Jersey client httpClient.readTimeout=1000 From 1d37125ae3afb37dd295d75473d81601e40d1c6a Mon Sep 17 00:00:00 2001 From: Mathis-Hu Date: Thu, 31 Aug 2023 10:25:08 -0400 Subject: [PATCH 11/11] Delete formula_functions.rst & add and.png --- app/display/editor/doc/formula_functions.rst | 3 --- .../src/main/resources/examples/pic/and.png | Bin 0 -> 1627 bytes 2 files changed, 3 deletions(-) delete mode 100644 app/display/editor/doc/formula_functions.rst create mode 100644 app/display/model/src/main/resources/examples/pic/and.png diff --git a/app/display/editor/doc/formula_functions.rst b/app/display/editor/doc/formula_functions.rst deleted file mode 100644 index 310e454160..0000000000 --- a/app/display/editor/doc/formula_functions.rst +++ /dev/null @@ -1,3 +0,0 @@ -================= -Formula Functions -================= diff --git a/app/display/model/src/main/resources/examples/pic/and.png b/app/display/model/src/main/resources/examples/pic/and.png new file mode 100644 index 0000000000000000000000000000000000000000..f917055ae50b1f47d5216aa93756df9de28ede9c GIT binary patch literal 1627 zcmbtVi8s`H6#rocW3r}EvW&fF#=b{s7|c+zjF4^2ka#`W8e{1gqcoUGL$dc8Q;}_u zJQ`A2U&>P12}#ehjS-co_v^erp?kjfe$MCI^F7~t?&qHS&2V#dl9W)C002M|kHdO^ z*z?oHMZs9@Q&S28B-Rd35C<(;JcI#qSQO4T769OTf4UG*SiBzqpu2c1hCnS|nF?a; z^8&ipYpZXtmWH((&o~aKW(dR7@35;b>i(<6kYHWn-ziNC{9DXkb31L`-cBA`v0DcD z<|Li!8xHYslfIkoTv1TSc3*w;yL9Yjm4(SCCb6$tH+I{DLlN`cR-c=ZmJe|?>%z~RoKctwBT5^}8jKVF`A9F$P)0_3wg(cexs67Y&OL9g zqj9ZDfVoH!tu{)^uO7MCs5&anoBYxw+IPT7jVw0`pjXdr-)tE*sKO}S21YK_i>F1( zNY|~_nmYKKqy`gR-+$cCEjL2MeNAx{T1vgyUMFm<%Nhv6gr=uP6V1j7s_=&=ij<%# z6*i3$WXxd`VH;;kOMKy0mO#o-QLQ#H1k(}^<%(KjlC-|=^HEg0pGd?c#tZRHqb?0= z6+ljPWK=}@WX~~yC0a^&K<-Cc>|6&y2aQ{g1SkV7nro~QjOQ~n&MKYe6>>kxuQfq6 zGuQnOF7kt-nA9Lo^B_M8<%{4X-x7ZJny0x`cGuGr!BNy`S1>i`B@YgH5t&;Cikr{f z*3Ss}iT8hnMEO08(`rCQbffDl`F9d*k5h2wQE0}vnQ*cbb=8)sP;G<2mgJwLgptmE zzvbj|N)FC;)zeCTyK6a>^5!TWft~WfQzgx@eRoCSawAsl=7JGo;W8PO*+cJ$KQeo; z?r2uNi%&LzcZ{mnrLpkf2%ME})s7L2%#|^kBl_u__poPc4mFwimBVP<;a57z-gDz% z;w7E);Wxp^d&pQffnWq@Nc54Kp4YD%dMS(!2U{EDe>5B9K`N!g!lj(smwdYUwf z3d0PUWGx3DO<0Oa>hKTPka2O?7W-n%e_T|#$3q^@W?xhpZQ~5d3uI947OW@wV&wD( z8gSM>9?Cv4H-jxHG&YD&>9`Y@Bm}yKW!Jl8;cR1n#Aw@- zA$celsr#JWPJye->i4ucd%h|59(rwxrGy1fkE5CSl@v6tFp@-z%ol*AKi1&x7CC#$ zchJkv#*02$D>uDt)8RaDZpJ_`5=vCvTcQhRm0sxy%CYU4=6zO{t|M?lQ&;?YR=vD0 zPo{A`$UQsR)~Z9Q8Lvl%!;WljSw;nR_&0`PhK%+oX{8(q1mFAF@lwqcy?ZnisEiq? zOmq9%d~Ijm|H=gG%{Gb$czHw7xMZ;X&D*9V{a_5~pm3Y^&NMliceYbeV~4cVeJ7$y zohN!8+vjBo4#(A;6)nNSkNt+Wfe+_=WiF6}q8R)gTP1_jR^VJ+P~(ftHopT|0?3RG zjyh7OrEj$6iC%-cqZ(4L!}`C5&*Yt5%zZ&8kaPKqlMQ5thj9}1$Pa$vJGhOQs;oTM z6TaCoQw|gzVnYn?n#GjX3wkbDn~yd;u@Q5wBS!NjUH&|bn=`CqH?59h$(_Munn>{M zmRh?G5GBVfZlj_RocIme+mNQtN4i}Qu8p(vg-&|hTEtAkjQmP~-#C0yQKP&i40AYE zmT$=|*>aAi@L)`APo;`)_JU*T*d? zSmyGWQdZA&P#jr~3Zsfzx*v0N80rnOcUm%%Oa}a4_o^QXs0(sSGj