Beispiel #1
0
func (fe *Frontend) SendAlert(msg interface{}) error {
	var mml cli.MultiLevelMessage
	switch typedMessage := msg.(type) {
	case *wtype.LHSolution:
		mesc := make([]cli.MultiLevelMessage, 0)
		for _, c := range typedMessage.Components {
			mesc = append(mesc, *cli.NewMultiLevelMessage(fmt.Sprintf("%s, %g", c.CName, c.Conc), nil))
		}
		mesC := *cli.NewMultiLevelMessage("Reagents", mesc)
		mesc1 := make([]cli.MultiLevelMessage, 0)
		mesc1 = append(mesc1, mesC)
		mml = *cli.NewMultiLevelMessage(fmt.Sprintf("%s @ %s", typedMessage.SName, typedMessage.Welladdress), mesc1)
	default:
		mml = *cli.NewMultiLevelMessage(fmt.Sprintf("%v", typedMessage), nil)
	}
	mesC := make([]cli.MultiLevelMessage, 0)
	mesC = append(mesC, mml)
	req := cli.NewCUICommandRequest("Alert", *cli.NewMultiLevelMessage(
		"Output",
		mesC,
	))

	fe.cui.CmdIn <- *req
	res := <-fe.cui.CmdOut
	return res.Error
}
Beispiel #2
0
//Perform an action in the equipment. Actions might be transmitted in blocks to the equipment
func (e AnthaManual) Do(actionDescription equipment.ActionDescription) error {
	//	fmt.Println("BEEN ASKED TO DO ", actionDescription.Action, " --> ", actionDescription.ActionData)

	id, err := uuid.NewV4()
	if err != nil {
		return err
	}
	levels := make([]cli.MultiLevelMessage, 0)
	levels = append(levels, *cli.NewMultiLevelMessage(fmt.Sprintf("%s", actionDescription.ActionData), nil))
	req := cli.NewCUICommandRequest(id.String(), *cli.NewMultiLevelMessage(
		fmt.Sprintf("%s", actionDescription.Action),
		levels,
	))

	e.Cui.CmdIn <- *req
	res := <-e.Cui.CmdOut
	if res.Error != nil {
		(*logger.GetLogger()).Log(*logger.NewLogEntry(e.GetID(), logger.ERROR, res.Error.Error(), ""))
		return errors.New(fmt.Sprintf("Manual Driver fail: id[%s]: %s", res.Id, res.Error))
	}
	(*logger.GetLogger()).Log(*logger.NewLogEntry(e.GetID(), logger.INFO, fmt.Sprintf("OK: %s.", actionDescription.ActionData), ""))

	return nil
}