Exemplo n.º 1
0
func (cortex *Cortex) Validate() bool {

	for _, neuron := range cortex.Neurons {
		if neuron.Cortex == nil {
			logg.LogWarn("Neuron: %v has no cortex", neuron.NodeId)
			return false
		}
	}

	for _, sensor := range cortex.Sensors {
		if sensor.Cortex == nil {
			logg.LogWarn("Sensor: %v has no cortex", sensor.NodeId)
			return false
		}
	}

	for _, actuator := range cortex.Actuators {
		if actuator.Cortex == nil {
			logg.LogWarn("Actuator: %v has no cortex", actuator.NodeId)
			return false
		}

	}

	return true
}
Exemplo n.º 2
0
func (e *OcrEngineType) UnmarshalJSON(b []byte) (err error) {

	var engineTypeStr string

	if err := json.Unmarshal(b, &engineTypeStr); err == nil {
		engineString := strings.ToUpper(engineTypeStr)
		switch engineString {
		case "TESSERACT":
			*e = ENGINE_TESSERACT
		case "GO_TESSERACT":
			*e = ENGINE_GO_TESSERACT
		case "MOCK":
			*e = ENGINE_MOCK
		default:
			logg.LogWarn("Unexpected OcrEngineType json: %v", engineString)
			*e = ENGINE_MOCK
		}
		return nil
	}

	// not a string .. maybe it's an int

	var engineTypeInt int
	if err := json.Unmarshal(b, &engineTypeInt); err == nil {
		*e = OcrEngineType(engineTypeInt)
		return nil
	} else {
		return err
	}

}