예제 #1
0
파일: manual.go 프로젝트: cgravill/antha
func (m *Manual) Init() { //TODO add the proper return statements with a commandStatus
	id, err := uuid.NewV4()
	if err != nil {
		panic(err) //TODO
	}
	m.Manager = *equipmentManager.NewAnthaEquipmentManager(id.String())
	idm, err := uuid.NewV4()
	if err != nil {
		panic(err) //TODO
	}
	var md equipment.Equipment
	md = manual.NewAnthaManual(idm.String())
	m.Manager.RegisterEquipment(&md)
}
예제 #2
0
파일: frontend.go 프로젝트: cgravill/antha
func NewFrontend() (*Frontend, error) {
	fe := &Frontend{}

	eid, err := uuid.NewV4()
	if err != nil {
		return nil, err
	}
	// TODO need to shudown equipmentmanager here on error
	fe.equipmentManager = equipmentManager.NewAnthaEquipmentManager(eid.String())
	fee := equipmentManager.EquipmentManager(fe.equipmentManager)
	equipmentManager.SetEquipmentManager(&fee)

	mid, err := uuid.NewV4()
	if err != nil {
		return nil, err
	}
	md := manual.NewAnthaManual(mid.String())
	mdd := equipment.Equipment(md)
	fe.equipmentManager.RegisterEquipment(&mdd)

	//cui logger middleware
	fe.cui = md.Cui
	cmw := middleware.NewLogToCui(&md.Cui)
	logId, err := uuid.NewV4()
	if err != nil {
		return nil, err
	}

	fe.logger = logger.NewAnthaFileLogger(logId.String())
	fe.logger.RegisterMiddleware(cmw)
	var logRef logger.Logger
	logRef = fe.logger
	logger.SetLogger(&logRef)

	var writer io.Writer
	if len(logFile) > 0 {
		w, err := os.OpenFile(logFile, os.O_WRONLY|os.O_CREATE, 0600)
		if err != nil {
			return nil, err
		}
		writer = w
	} else {
		writer = ioutil.Discard
	}

	fe.debugLogger = log.New(writer, "", log.LstdFlags)

	return fe, nil
}