Example #1
0
File: sim.go Project: cycps/addie
/*The GenerateSourceFromDB function generates Cypress simulation source for a
design given its name. This function reads the design from the database based
on the provided name. If you already have the design in memory use the
GenerateSource function.
*/
func GenerateSourceFromDB(designName, user string) (string, error) {

	dsg, err := db.ReadDesign(designName, user)
	if err != nil {
		log.Println(err)
		return "", fmt.Errorf("Failed to read design")
	}

	models, err := db.ReadUserModels(user)
	if err != nil {
		log.Println(err)
		return "", fmt.Errorf("failed to read user models")
	}

	return GenerateSource(dsg, models), nil

}
Example #2
0
File: main.go Project: cycps/addie
func doRead() error {

	dsg, err := db.ReadDesign(design.Name, user)
	if err != nil {
		log.Println(err)
		return fmt.Errorf("Failed to read design")
	}

	design = *dsg

	mls, err := db.ReadUserModels(user)
	if err != nil {
		log.Println(err)
		return fmt.Errorf("failed to read user models")
	}

	userModels = make(map[string]addie.Model)

	for _, v := range mls {
		userModels[v.Name] = v
	}

	design_key, err := db.ReadDesignKey(dsg.Name, user)
	if err != nil {
		log.Println(err)
		return fmt.Errorf("error reading design key")
	}

	ss, err := db.ReadSimSettingsByDesignId(design_key)
	if err != nil {
		log.Println(err)
		return fmt.Errorf("could not read simulation settings")
	}

	simSettings = *ss

	return nil
}