fix
This commit is contained in:
+44
-17
@@ -21,20 +21,47 @@ type ControlCase struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
func (c ControlCase) FooCSVPath() string {
|
||||
paramsID := c.ParamsID
|
||||
if paramsID == 0 {
|
||||
paramsID = c.Params.ID
|
||||
}
|
||||
return filepath.Join(BASE_DIR, fmt.Sprintf("%d", paramsID), "foo.csv")
|
||||
}
|
||||
|
||||
func (c ControlCase) StorageH5Path() string {
|
||||
paramsID := c.ParamsID
|
||||
if paramsID == 0 {
|
||||
paramsID = c.Params.ID
|
||||
}
|
||||
return filepath.Join(BASE_DIR, fmt.Sprintf("%d", paramsID), "storage.h5")
|
||||
}
|
||||
|
||||
func (c ControlCase) CreateStorageH5FromLastState(outputPath string) error {
|
||||
return CopyLastStateStorageH5(c.StorageH5Path(), outputPath)
|
||||
}
|
||||
|
||||
type Params struct {
|
||||
ID uint `gorm:"primaryKey" json:"id" toml:"-" csv:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
|
||||
Rel float64 `json:"rel" toml:"rel" csv:"rel"`
|
||||
RelC float64 `json:"rel_c" toml:"rel_c" csv:"rel_c"`
|
||||
Le float64 `json:"le" toml:"le" csv:"le"`
|
||||
Pr float64 `json:"pr" toml:"pr" csv:"pr"`
|
||||
Pe float64 `json:"pe" toml:"pe" csv:"pe"`
|
||||
Ma float64 `json:"ma" toml:"ma" csv:"ma"`
|
||||
InitialCondition string `json:"initial_condition" toml:"-" csv:"initial_condition"`
|
||||
Time float64 `json:"time" toml:"time" csv:"time"`
|
||||
FolderPath string `json:"folder_path" toml:"-" csv:"-"`
|
||||
ID uint `gorm:"primaryKey" json:"id" toml:"-" csv:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
|
||||
Rel float64 `json:"rel" toml:"rel" csv:"rel"`
|
||||
RelC float64 `json:"rel_c" toml:"rel_c" csv:"rel_c"`
|
||||
Le float64 `json:"le" toml:"le" csv:"le"`
|
||||
Sc float64 `json:"sc" toml:"sc" csv:"sc"`
|
||||
Pe float64 `json:"pe" toml:"pe" csv:"pe"`
|
||||
Ma float64 `json:"ma" toml:"ma" csv:"ma"`
|
||||
InitialConditionID *uint `json:"initial_condition_id" toml:"-" csv:"initial_condition_id"`
|
||||
InitialCondition *InitialCondition `json:"initial_condition" toml:"-" csv:"-"`
|
||||
Time float64 `json:"time" toml:"time" csv:"time"`
|
||||
FolderPath string `json:"folder_path" toml:"-" csv:"-"`
|
||||
}
|
||||
|
||||
type InitialCondition struct {
|
||||
gorm.Model
|
||||
Name string `json:"name"`
|
||||
FilePath string `json:"file_path"`
|
||||
}
|
||||
|
||||
func (p *Params) ToTOML(filename string) error {
|
||||
@@ -49,12 +76,12 @@ func (p *Params) ToTOML(filename string) error {
|
||||
}
|
||||
|
||||
func (p *Params) Exist() (bool, error) {
|
||||
folderPath := filepath.Join("./", fmt.Sprintf("%d", p.ID))
|
||||
folderPath := filepath.Join(BASE_DIR, fmt.Sprintf("%d", p.ID))
|
||||
return exists(folderPath)
|
||||
}
|
||||
func (p *Params) CreateFolder() error {
|
||||
BIN_PATH := "./bio-convect"
|
||||
folderPath := filepath.Join("./", fmt.Sprintf("%d", p.ID))
|
||||
folderPath := filepath.Join(BASE_DIR, fmt.Sprintf("%d", p.ID))
|
||||
if err := os.MkdirAll(folderPath, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -67,9 +94,9 @@ func (p *Params) CreateFolder() error {
|
||||
if err := os.Chmod(execPath, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if p.InitialCondition != "" && p.InitialCondition != "E" {
|
||||
if p.InitialCondition != nil && p.InitialCondition.FilePath != "" {
|
||||
startPath := filepath.Join("./", folderPath, "storage.h5")
|
||||
err = copy.Copy(p.InitialCondition, startPath)
|
||||
err = copy.Copy(p.InitialCondition.FilePath, startPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user