Skip to content
This repository has been archived by the owner on Jun 25, 2019. It is now read-only.

Minor cleanup logging and templates #67

Merged
merged 1 commit into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Minor cleanup logging and templates
  • Loading branch information
andig committed Sep 20, 2018
commit eecdcdb549a218996a4d7f0402d1815e675aa7c9
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ indent_size = 4

[*.css]
indent_size = 2

[*.js]
indent_size = 2

[*.html]
indent_size = 2
6 changes: 4 additions & 2 deletions assets/css/app.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
body {
padding-top: 5rem;
}
.mainsection {
padding: 3rem 1.5rem;
@media (min-width: 576px) {
.container > div {
padding: 3rem 1.5rem;
}
}
.metertable {
padding: 3rem 1.5rem;
Expand Down
28 changes: 14 additions & 14 deletions assets/index.tmpl → assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta charset="utf-8">
<title>GoSDM630</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=yes" />
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
<link href="/static/css/app.css" rel="stylesheet">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link href="css/app.css" rel="stylesheet">
</head>

<body>
Expand Down Expand Up @@ -38,7 +38,7 @@
</nav>

<div class="container">
<div id="realtime" class="mainsection">
<div id="realtime">
<h1>Realtime measurements</h1>
<div id="meters">
<p>${ message }</p>
Expand All @@ -54,21 +54,21 @@ <h1>Realtime measurements</h1>
</thead>
<tbody>
<tr v-if="meter.VolLocPhsA != null || meter.VolLocPhsB != null || meter.VolLocPhsC != null">
<td>Voltage (Volt)</td>
<td>Voltage (V)</td>
<td>${ meter.VolLocPhsA }</td>
<td>${ meter.VolLocPhsB }</td>
<td>${ meter.VolLocPhsC }</td>
<td>-</td>
</tr>
<tr v-if="meter.AmpLocPhsA != null || meter.AmpLocPhsB != null || meter.AmpLocPhsC != null">
<td>Current (Ampere)</td>
<td>Current (A)</td>
<td>${ meter.AmpLocPhsA }</td>
<td>${ meter.AmpLocPhsB }</td>
<td>${ meter.AmpLocPhsC }</td>
<td>${ (parseFloat(meter.AmpLocPhsA) + parseFloat(meter.AmpLocPhsB) + parseFloat(meter.AmpLocPhsC)).toFixed(2) }</td>
</tr>
<tr v-if="meter.WLocPhsA != null || meter.WLocPhsB != null || meter.WLocPhsC != null">
<td>Power (Watt)</td>
<td>Power (W)</td>
<td>${ meter.WLocPhsA }</td>
<td>${ meter.WLocPhsB }</td>
<td>${ meter.WLocPhsC }</td>
Expand All @@ -81,7 +81,7 @@ <h1>Realtime measurements</h1>
<td>${ meter.AngLocPhsC }</td>
<td>-</td>
</tr>
<tr>
<tr v-if="meter.TotkWhImportPhsA != null || meter.TotkWhImportPhsB != null || meter.TotkWhImportPhsC != null || meter.TotkWhImport != null">
<td>Import (kWh)</td>
<td>${ meter.TotkWhImportPhsA }</td>
<td>${ meter.TotkWhImportPhsB }</td>
Expand Down Expand Up @@ -113,7 +113,7 @@ <h1>Realtime measurements</h1>
</table>
</div>
</div>
<div id="status" class="mainsection">
<div id="status">
<h1>Current Meter Status</h1>
<div id="status">
<table class="metertable table table-striped">
Expand All @@ -135,7 +135,7 @@ <h1>Current Meter Status</h1>
</div>
</div>

<div id="about" class="mainsection">
<div id="about">
<h1>About GoSDM630</h1>
<p>GoSDM630 is an interface for the Eastron SDM/Modbus Smart Meter series. Please
<a href="https://github.com/gonium/gosdm630">refer to the documentation
Expand All @@ -144,11 +144,11 @@ <h1>About GoSDM630</h1>
</div>
</div>
<!-- /.container -->
<script src="/static/js/jquery-3.2.1.min.js"></script>
<script src="/static/js/tether.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/vue.min.js"></script>
<script src="/static/js/app.js"></script>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/tether.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/vue.min.js"></script>
<script src="js/app.js"></script>
</body>

</html>
15 changes: 0 additions & 15 deletions assets/simple.tmpl

This file was deleted.

4 changes: 2 additions & 2 deletions cmd/sdm630/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func main() {
},
cli.StringFlag{
Name: "unique_id_format, f",
Value: "Instrument%d",
Value: "Meter#%d",
Usage: `Unique ID format.
Example: -f Instrument%d
Example: -f Meter#%d
The %d is replaced by the device ID`,
},
cli.BoolFlag{
Expand Down
10 changes: 5 additions & 5 deletions datagram.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func Fp2f(x *float64) float64 {
}

func (r *Readings) String() string {
fmtString := "UniqueId: %s ID: %d T: %s - L1: %.2fV %.2fA %.2fW %.2fcos | " +
"L2: %.2fV %.2fA %.2fW %.2fcos | " +
"L3: %.2fV %.2fA %.2fW %.2fcos"
fmtString := "%s " +
"L1: %.1fV %.2fA %.0fW %.2fcos | " +
"L2: %.1fV %.2fA %.0fW %.2fcos | " +
"L3: %.1fV %.2fA %.0fW %.2fcos | " +
"%.1fHz"
return fmt.Sprintf(fmtString,
r.UniqueId,
r.ModbusDeviceId,
r.Timestamp.Format(time.RFC3339),
Fp2f(r.Voltage.L1),
Fp2f(r.Current.L1),
Fp2f(r.Power.L1),
Expand Down
2 changes: 1 addition & 1 deletion http.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (

func MkIndexHandler(hc *MeasurementCache) func(http.ResponseWriter, *http.Request) {
loader := GetEmbeddedContent()
mainTemplate, err := loader.GetContents("/index.tmpl")
mainTemplate, err := loader.GetContents("/index.html")
if err != nil {
log.Fatal("Failed to load embedded template: " + err.Error())
}
Expand Down