diff options
Diffstat (limited to 'src/rhctl/playout_server.go')
-rw-r--r-- | src/rhctl/playout_server.go | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/rhctl/playout_server.go b/src/rhctl/playout_server.go new file mode 100644 index 0000000..02533de --- /dev/null +++ b/src/rhctl/playout_server.go @@ -0,0 +1,72 @@ +// +// rhctl +// +// Copyright (C) 2009-2016 Christian Pointner <equinox@helsinki.at> +// +// This file is part of rhctl. +// +// rhctl is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// rhctl 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 rhctl. If not, see <http://www.gnu.org/licenses/>. +// + +package main + +import ( + "fmt" +) + +type ServerHealth bool + +const ( + Dead ServerHealth = false + Alive = true +) + +type ServerChannel uint + +const ( + Main ServerChannel = iota + Music +) + +type PlayoutServer struct { + name string + control *SerialPort + heartbeat *SerialPort + health ServerHealth + channel ServerChannel +} + +func (srv *PlayoutServer) Run() { + rhdl.Printf("running playout server: %s", srv.name) + srv.control.tx <- "hello world" + srv.heartbeat.tx <- "hello world" +} + +func ServerInit(name string, ctrldev, hbdev string, rate Baudrate) (srv *PlayoutServer, err error) { + srv = &PlayoutServer{} + srv.name = name + srv.health = Dead + srv.channel = Music + + if srv.control, err = SerialOpenAndHandle(ctrldev, rate); err != nil { + err = fmt.Errorf("Error opening control port(%s): %s", srv.name, err) + return + } + if srv.heartbeat, err = SerialOpenAndHandle(hbdev, rate); err != nil { + err = fmt.Errorf("Error opening control port(%s): %s", srv.name, err) + return + } + + return +} |