Commit 1b62805a authored by Stéphane LOS's avatar Stéphane LOS
Browse files

demo/142 a4a_k0_S7 : added a dashboard using JustGage.js

parent 464893a7
.jg-container {
width: 450px;
margin: 50px auto 0 auto;
text-align: center;
}
.jg-gauge {
width: 450px;
height: 450px;
}
......@@ -105,7 +105,7 @@
<a href="#s7-plc">
<i class="fa fa-arrow-up w3-large w3-right"></i>
</a>
<a href="#bottom">
<a href="#s7-dashboard">
<i class="fa fa-arrow-down w3-large w3-right"></i>
</a>
</header>
......@@ -220,6 +220,36 @@
</div>
</div>
</section>
<section id="s7-dashboard" class="w3-section">
<header class="w3-container w3-light-blue w3-padding-8">
<h1>S7 Dashboard</h1>
<a href="#s7-com">
<i class="fa fa-arrow-up w3-large w3-right"></i>
</a>
<a href="#bottom">
<i class="fa fa-arrow-down w3-large w3-right"></i>
</a>
</header>
<div class="w3-row">
<div class="w3-container w3-quarter jg-container">
<h2>MW0 Gauge</h2>
<div id="MW0-gauge"></div>
</div>
<div class="w3-container w3-quarter jg-container">
<h2>DB1.DBW0 Gauge</h2>
<div id="DB1-DBW0-gauge"></div>
</div>
<div class="w3-container w3-quarter jg-container">
<h2>IW0 Gauge</h2>
<div id="IW0-gauge"></div>
</div>
<div class="w3-container w3-quarter jg-container">
<h2>QW0 Gauge</h2>
<div id="QW0-gauge"></div>
</div>
<script src="/js/mygauges.js"></script>
</div>
</section>
</div>
<noscript>Your browser must support JavaScript and be HTML 5 compliant to see this site.</noscript>
</body>
......
This diff is collapsed.
var MW0_Gauge = new JustGage({
id: "MW0-gauge",
label: "units",
value: 0,
min: -32768,
max: 32767,
decimals: 0,
gaugeWidthScale: 0.6
});
var DB1_DBW0_Gauge = new JustGage({
id: "DB1-DBW0-gauge",
label: "units",
value: 0,
min: -32768,
max: 32767,
decimals: 0,
gaugeWidthScale: 0.6
});
var IW0_Gauge = new JustGage({
id: "IW0-gauge",
label: "units",
value: 0,
min: -32768,
max: 32767,
decimals: 0,
gaugeWidthScale: 0.6
});
var QW0_Gauge = new JustGage({
id: "QW0-gauge",
label: "units",
value: 0,
min: -32768,
max: 32767,
decimals: 0,
gaugeWidthScale: 0.6
});
This diff is collapsed.
......@@ -34,6 +34,7 @@ with A4A.Protocols; use A4A.Protocols.IP_Address_Strings;
with A4A.Application.S7_Client_Config;
with Gnoga.Server;
with Gnoga.Gui.Plugin.JustGage;
with A4A.Web.Web_Server_Config;
with A4A.Web.Pages.General_Status;
......@@ -143,6 +144,11 @@ package body A4A.Web.Web_Server is
App_Data.S7_View.MW0_View.Inner_HTML
(Integer'Image (Integer (Word_To_Int (MW0))));
App_Data.S7_View.MW0 := MW0;
Gnoga.Gui.Plugin.JustGage.Gauge_Refresh
(ID => App_Data.Main_Window.Connection_ID,
Gauge => "MW0_Gauge",
Value => Integer'Image (Integer (Word_To_Int (MW0))));
end if;
if MW2 /= App_Data.S7_View.MW2 then
......@@ -168,16 +174,31 @@ package body A4A.Web.Web_Server is
if IW0 /= App_Data.S7_View.IW0 then
App_Data.S7_View.IW0_View.Inner_HTML (IW0'Img);
App_Data.S7_View.IW0 := IW0;
Gnoga.Gui.Plugin.JustGage.Gauge_Refresh
(ID => App_Data.Main_Window.Connection_ID,
Gauge => "IW0_Gauge",
Value => Integer'Image (Integer (Word_To_Int (IW0))));
end if;
if QW0 /= App_Data.S7_View.QW0 then
App_Data.S7_View.QW0_View.Inner_HTML (QW0'Img);
App_Data.S7_View.QW0 := QW0;
Gnoga.Gui.Plugin.JustGage.Gauge_Refresh
(ID => App_Data.Main_Window.Connection_ID,
Gauge => "QW0_Gauge",
Value => Integer'Image (Integer (Word_To_Int (QW0))));
end if;
if DB1_W0 /= App_Data.S7_View.DB1_W0 then
App_Data.S7_View.DB1_W0_View.Inner_HTML (DB1_W0'Img);
App_Data.S7_View.DB1_W0 := DB1_W0;
Gnoga.Gui.Plugin.JustGage.Gauge_Refresh
(ID => App_Data.Main_Window.Connection_ID,
Gauge => "DB1_W0_Gauge",
Value => Integer'Image (Integer (Word_To_Int (DB1_W0))));
end if;
if T1 /= App_Data.S7_View.T1 then
......@@ -232,6 +253,9 @@ package body A4A.Web.Web_Server is
Main_Window.Document.Load_CSS (W3_CSS_URL);
Main_Window.Document.Load_CSS (Font_Awesome_CSS_URL);
Main_Window.Document.Load_CSS (APP_CSS_URL);
Main_Window.Document.Load_CSS ("/css/justgage.css");
Gnoga.Gui.Plugin.JustGage.Load_JustGage (Main_Window);
Connection_Stats_Controller.Connection;
......
------------------------------------------------------------------------------
-- --
-- GNOGA - The GNU Omnificent GUI for Ada --
-- --
-- G N O G A . G U I . P L U G I N . J U S T G A G E --
-- --
-- B o d y --
-- --
-- --
-- Copyright (C) 2021 Stéphane LOS --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are --
-- granted additional permissions described in the GCC Runtime Library --
-- Exception, version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- For more information please go to http://www.gnoga.com --
------------------------------------------------------------------------------
with Gnoga.Server.Connection;
package body Gnoga.Gui.Plugin.JustGage is
-------------------
-- Load_JustGage --
-------------------
procedure Load_JustGage
(Window : in out Gnoga.Gui.Window.Window_Type'Class) is
begin
Window.Document.Head_Element.jQuery_Execute
("append('" &
Escape_Quotes
("<script src='/js/raphael.min.js'"
& " type='text/javascript' charset='utf-8'></script>"
& "<script src='/js/justgage.js'"
& " type='text/javascript' charset='utf-8'></script>")
& "')");
end Load_JustGage;
procedure Gauge_Refresh
(ID : in Gnoga.Types.Connection_ID;
Gauge : in String;
Value : String) is
Result : constant String := Gnoga.Server.Connection.Execute_Script
(ID => ID,
Script => Escape_Quotes (Gauge & ".refresh('" & Value & "');"));
begin
null;
end Gauge_Refresh;
end Gnoga.Gui.Plugin.JustGage;
------------------------------------------------------------------------------
-- --
-- GNOGA - The GNU Omnificent GUI for Ada --
-- --
-- G N O G A . G U I . P L U G I N . J U S T G A G E --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 2021 Stéphane LOS --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are --
-- granted additional permissions described in the GCC Runtime Library --
-- Exception, version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- For more information please go to http://www.gnoga.com --
------------------------------------------------------------------------------
with Gnoga.Types;
with Gnoga.Gui.Window;
package Gnoga.Gui.Plugin.JustGage is
-- JustGage Ada API is inspired by https://github.com/toorshia/justgage.
-- JustGage.js is released under the (http://opensource.org/licenses/MIT)
-- MIT License.
-- Some comments come from JustGage.js documentation:
-- JustGage.js is a handy JavaScript plugin for generating and animating
-- nice & clean gauges. It is based on Raphaël library for vector drawing,
-- so it's completely resolution independent and self-adjusting.
-- Oh yes, since it's pure SVG, it works in almost any browser -
-- IE6+, Chrome, Firefox, Safari, Opera, Android, etc.
procedure Load_JustGage
(Window : in out Gnoga.Gui.Window.Window_Type'Class);
-- Load JustGage code into Window
procedure Gauge_Refresh
(ID : in Gnoga.Types.Connection_ID;
Gauge : in String;
Value : String);
-- Refresh the gauge
end Gnoga.Gui.Plugin.JustGage;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment