Ejemplo n.º 1
0
func NewAgentProxy(send link.SendLink, recv link.RecvLink) *AgentProxy {
	self := new(AgentProxy)
	//     self.state = NewAgentState(0, geo.NewPoint(0, 0), 0)
	self.snd = send
	self.rcv = recv
	self.log = logflow.NewSource("agentproxy/?")
	return self
}
Ejemplo n.º 2
0
func New(c *coord.Coordinator, address string) *CoordRunner {
	r := &CoordRunner{
		myCoord:   c,
		masterReq: make(CoordComm),
		masterRsp: make(CoordComm),
		log:       logflow.NewSource(fmt.Sprintf("coordrunner/%v", address)),
	}
	c.Config().Address = address
	return r
}
Ejemplo n.º 3
0
func NewCoordProxy(identifier int, parentIdentifier int,
	address string,
	sendChan chan game.GameStateRequest,
	recvChan chan game.GameStateResponse) *CoordinatorProxy {
	return &CoordinatorProxy{identifier,
		parentIdentifier,
		address,
		sendChan,
		recvChan,
		logflow.NewSource(fmt.Sprintf("coordproxy/%d/%d: ", parentIdentifier, identifier))}
}
Ejemplo n.º 4
0
func NewRandomBot(id uint32) *RandomBot {
	self := &RandomBot{
		id:     id,
		logger: logflow.NewSource(fmt.Sprintf("agent/wifi/randmv/%d", id)),
	}
	self.hello = NewHelloMachine(1, self)
	self.route = NewRouteMachine(2, self)
	self.send = NewSendMachine(3, self)
	//     logflow.FileSink("logs/wifi/all", true, ".*")
	return self
}
Ejemplo n.º 5
0
func NewSendMachine(freq uint8, agent agent.Agent) *SendMachine {
	self := &SendMachine{
		freq:       freq,
		logger:     logflow.NewSource(fmt.Sprintf("agent/wifi/send/%d", agent.Id())),
		agent:      agent,
		backoff:    BACKOFF,
		wait:       ROUTE_HOLDTIME,
		state:      2,
		next_state: 0,
		sendq:      NewDataGramQueue(),
	}
	return self
}
Ejemplo n.º 6
0
func NewStaticBot(id, first, last uint32) *StaticBot {
	self := &StaticBot{
		id:       id,
		first:    first,
		last:     last,
		next:     first - 1,
		logger:   logflow.NewSource(fmt.Sprintf("agent/wifi/static/%d", id)),
		recieved: make([]uint32, 0, int(last-first)),
	}
	self.hello = NewHelloMachine(1, self)
	self.route = NewRouteMachine(15, self)
	self.send = NewSendMachine(3, self)
	//     logflow.FileSink("logs/wifi/all", true, ".*")
	return self
}
Ejemplo n.º 7
0
func MakeImporterWithRetry(network string, remoteaddr string, n int, log logflow.Logger) *netchan.Importer {
	if log == nil {
		log = logflow.NewSource("util")
	}
	var err os.Error
	for i := 0; i < n; i++ {
		conn, err := net.Dial(network, "", remoteaddr)
		if err == nil {
			return netchan.NewImporter(conn)
		}
		log.Print("Netchan import failed, retrying")
		time.Sleep(1e9 / 2)
	}
	log.Print("Netchan import failed ", n, " times. Bailing out.")
	log.Fatal(err)
	return nil
}
Ejemplo n.º 8
0
func New(args []string) *Master {
	mc := new(MasterConfig)

	txt, err := ioutil.ReadFile(args[1])
	if err != nil {
		log.Fatal(err)
	}
	err = json.Unmarshal(txt, mc)
	if err != nil {
		log.Fatal(err)
	}

	m := &Master{
		conf: mc,
		log:  logflow.NewSource("master"),
	}

	m.conf.Logs.Apply()

	m.log.Print("Configured.")

	return m
}
Ejemplo n.º 9
0
import "fmt"
import pseudo_rand "rand"
import crypto_rand "crypto/rand"
import "sort"
import geo "coord/geometry"
import cagent "coord/agent"
import "logflow"
import "sync"
import . "byteslice"

const MessageLength = 64
const HearingRange = 10.0
const corrupt_scale = 1.137
const combine_scale = corrupt_scale * 3

var log logflow.Logger = logflow.NewSource(fmt.Sprint("message"))

type sortableMessages struct {
	msgs []cagent.Message
	targ geo.Point
}
type Messages struct {
	Msgs  map[uint8][]cagent.Message
	Cache map[complex128](map[uint8][]byte)
	mu    sync.Mutex
}

// initializer for random number generator -------------------------------------
func init() {
	// This function was a originally part of the structure/block/byteslice pkg
	// in SourceQL
Ejemplo n.º 10
0
func (self *AgentProxy) SetState(state *AgentState) {
	self.state = state
	self.log = logflow.NewSource(fmt.Sprintf("agentproxy/%v", self.state.Id))
}