// // rhctl // // Copyright (C) 2009-2016 Christian Pointner // // 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 . // package main import ( "fmt" ) type ServerHealth bool const ( Dead ServerHealth = false Alive = true ) type PlayoutServer struct { name string control *SerialPort heartbeat *SerialPort health ServerHealth channel string } func (srv *PlayoutServer) Run() { rhdl.Printf("running playout server: %s", srv.name) srv.control.tx <- fmt.Sprintf("hello %s", srv.name) srv.heartbeat.tx <- fmt.Sprintf("beat %s", srv.name) } 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, "\r\n"); err != nil { err = fmt.Errorf("Error opening control port(%s): %s", srv.name, err) return } if srv.heartbeat, err = SerialOpenAndHandle(hbdev, rate, "\r\n"); err != nil { err = fmt.Errorf("Error opening control port(%s): %s", srv.name, err) return } return }