summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-14 22:33:21 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-14 22:33:21 (GMT)
commitacb7951546895ff72929ce542a3ae67a3c71ad8f (patch)
tree023802d46223447054c54ee421ee13fb9072166b
parent5d8bd7f5503c7d4cf0a179b8f1eea798be077098 (diff)
include cart/cut in progress if available
-rw-r--r--src/rhimportd/ctrlTelnet.go8
-rw-r--r--src/rhimportd/ctrlWebSocket.go12
2 files changed, 14 insertions, 6 deletions
diff --git a/src/rhimportd/ctrlTelnet.go b/src/rhimportd/ctrlTelnet.go
index 4177128..ae4b8f7 100644
--- a/src/rhimportd/ctrlTelnet.go
+++ b/src/rhimportd/ctrlTelnet.go
@@ -264,9 +264,13 @@ func telnetShow(c *telgo.Client, args []string, conf *rhimport.Config, db *rddb.
return false
}
-func telnetProgressCallback(step int, stepName string, current, total float64, userdata interface{}) bool {
+func telnetProgressCallback(step int, stepName string, current, total float64, cart, cut uint, userdata interface{}) bool {
c := userdata.(*telgo.Client)
- c.Say("%s: %3.2f%%\r", stepName, (current/total)*100)
+ if cart > 0 {
+ c.Say("%s: %3.2f%% (Cart/Cut: %d/%d)\r", stepName, (current/total)*100, cart, cut)
+ } else {
+ c.Say("%s: %3.2f%%\r", stepName, (current/total)*100)
+ }
return true
}
diff --git a/src/rhimportd/ctrlWebSocket.go b/src/rhimportd/ctrlWebSocket.go
index a22c134..d522546 100644
--- a/src/rhimportd/ctrlWebSocket.go
+++ b/src/rhimportd/ctrlWebSocket.go
@@ -99,6 +99,8 @@ type webSocketResponseProgressData struct {
Current float64 `json:"CURRENT"`
Total float64 `json:"TOTAL"`
Progress float64 `json:"PROGRESS"`
+ Cart uint `json:"CART_NUMBER"`
+ Cut uint `json:"CUT_NUMBER"`
}
type webSocketResponseDoneData struct {
@@ -140,7 +142,7 @@ func sendWebSocketListResponse(ws *websocket.Conn, sessions map[string]string) {
sendWebSocketResponse(ws, rd)
}
-func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step int, stepName string, current, total float64) {
+func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step int, stepName string, current, total float64, cart, cut uint) {
progress := current / total
if math.IsNaN(progress) || math.IsInf(progress, 0) {
progress = 0.0
@@ -157,6 +159,8 @@ func sendWebSocketProgressResponse(ws *websocket.Conn, id, refid string, step in
rd.Current = current
rd.Total = total
rd.Progress = progress * 100
+ rd.Cart = cart
+ rd.Cut = cut
sendWebSocketResponse(ws, rd)
}
@@ -187,7 +191,7 @@ func newWebSocketSession() *webSocketSession {
return session
}
-func webSocketProgress(step int, stepName string, current, total float64, userdata interface{}) bool {
+func webSocketProgress(step int, stepName string, current, total float64, cart, cut uint, userdata interface{}) bool {
if math.IsNaN(current) || math.IsInf(current, 0) {
current = 0.0
}
@@ -196,7 +200,7 @@ func webSocketProgress(step int, stepName string, current, total float64, userda
}
c := userdata.(chan<- rhimport.ProgressData)
select {
- case c <- rhimport.ProgressData{Step: step, StepName: stepName, Current: current, Total: total}:
+ case c <- rhimport.ProgressData{Step: step, StepName: stepName, Current: current, Total: total, Cart: cart, Cut: cut}:
default:
}
return true
@@ -311,7 +315,7 @@ func webSocketSessionHandler(reqchan <-chan webSocketRequestData, binchan <-chan
sendWebSocketErrorResponse(ws, http.StatusBadRequest, fmt.Sprintf("unknown command '%s'", reqdata.Command))
}
case p := <-session.progresschan:
- sendWebSocketProgressResponse(ws, session.id, session.refId, p.Step, p.StepName, p.Current, p.Total)
+ sendWebSocketProgressResponse(ws, session.id, session.refId, p.Step, p.StepName, p.Current, p.Total, p.Cart, p.Cut)
case d := <-session.donechan:
sendWebSocketDoneResponse(ws, d.ResponseCode, d.ErrorString, session.id, session.refId, d.Cart, d.Cut)
rhdl.Println("WebSocket Client", ws.RemoteAddr(), "done sent: sending close message.")