ready for some testing

This commit is contained in:
Saxon1 2018-04-19 16:33:12 +09:30
parent f50e1085b2
commit 0381a5dda0
1 changed files with 80 additions and 26 deletions

View File

@ -1,3 +1,30 @@
/*
NAME
RevidCLI.go
DESCRIPTION
See Readme.md
AUTHORS
Saxon A. Nelson-Milton <saxon@ausocean.org>
Jack Richardson <jack@ausocean.org>
LICENSE
RevidCLI.go is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It 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. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with revid in gpl.txt. If not, see [GNU licenses](http://www.gnu.org/licenses).
*/
package main
import (
@ -76,8 +103,10 @@ func main() {
flags[i] = flag.String(flagNames[i][0], "", flagNames[i][1])
}
// Do we want a netsender session
netSenderFlagPtr := flag.Bool("netSender", false, "Are we checking vars through netsender?")
runDurationPtr := flag.Int("runDuration",defaultRunDuration,"how long do you want revid to run for?")
// User might also want to define how long revid runs for
runDurationPtr := flag.Int("runDuration",defaultRunDuration,"How long do you want revid to run for?")
flag.Parse()
@ -147,25 +176,18 @@ func main() {
config.Timeout = flags[timeoutPtr]
config.IntraRefreshPeriod = flags[intraRefreshPeriodPtr]
// Try to create the revid instance with the given config
for revid, err := NewRevid(config); err != nil; {
// If the config does have a logger, use it to output error, otherwise
// just output to std output
if config.Logger != nil {
config.Logger.Log("FATAL ERROR", err)
} else {
fmt.Printf("FATAL ERROR: %v", err)
}
}
createRevidInstance()
revid.Start()
// Is the netsender flag been used ? if so run this loop
for *netSenderFlagPtr {
periodicNetsenderReport()
sleepTime, err := strconv.Atoi(netsender.GetConfigParam("monPeriod"))
time.Sleep(time.Duration(sleepTime) * time.Second)
}
// If we're not running a netsender session then we run revid for the amount
// of time the user defined or the default 2 days
time.Sleep( time.Duration(*runDurationPtr) * time.Second )
revid.Stop()
}
@ -212,43 +234,62 @@ func periodicNetsenderReport(){
}
func updateRevid() {
revid.Stop()
time.Sleep( time.Duration(revidStopTime) * time.Second )
for key, value := range vars {
switch key {
case "FramesPerClip":
asInt,err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.FramesPerClip = value
}
case "RtmpUrl":
config.RtmpUrl = value
case "Bitrate":
asInt,err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.Bitrate = value
}
case "OutputFileName":
config.OutputFileName = value
case "InputFileName":
config.InputFileName = value
case "Height":
asInt,err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.Height = value
}
case "Width":
asInt,err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.Width = value
}
case "FrameRate":
asInt,err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.FrameRate = value
}
case "HttpAddress":
config.HttpAddress = value
case "Quantization":
asInt,err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.Quantization = value
}
case "Timeout":
asInt,err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.Timeout = value
}
case "IntraRefreshPeriod":
asInt,err := strconv.Atoi(value)
if asInt > 0 && err == nil {
confog.IntraRefreshPeriod = value
}
}
revid, err := Newrevidance(config)
if err != nil {
fmt.Println(err)
}
createRevidInstance()
revid.Start()
}
@ -340,3 +381,16 @@ func revidReportActions(pin int) (int, error) {
return -1, errors.New("External pin not defined")
}
}
func createRevidInstance(){
// Try to create the revid instance with the given config
for revid, err := NewRevid(config); err != nil; {
// If the config does have a logger, use it to output error, otherwise
// just output to std output
if config.Logger != nil {
config.Logger.Log("FATAL ERROR", err)
} else {
fmt.Printf("FATAL ERROR: %v", err)
}
}
}