models

package
v0.0.0-...-5ebd1d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 23 Imported by: 10

Documentation

Overview

Default generated models package docs (at least one file is necessary in a models package)

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

generated code - do not edit

Index

Constants

View Source
const IdentifiersDecls = `
	{{Identifier}} := (&models.{{GeneratedStructName}}{Name: ` + "`" + `{{GeneratedFieldNameValue}}` + "`" + `}).Stage(stage)`
View Source
const NumberInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const PointerFieldInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const RFC3339MillisFormat = "2006-01-02T15:04:05.000Z07:00"
View Source
const SliceOfPointersFieldInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = append({{Identifier}}.{{GeneratedFieldName}}, {{GeneratedFieldNameValue}})`
View Source
const StringEnumInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = {{GeneratedFieldNameValue}}`
View Source
const StringInitStatement = `
	{{Identifier}}.{{GeneratedFieldName}} = ` + "`" + `{{GeneratedFieldNameValue}}` + "`"
View Source
const TimeInitStatement = `` /* 129-byte string literal not displayed */

Variables

View Source
var CpuProfile bool
View Source
var DisplayWatch bool
View Source
var Quit chan bool

Functions

func AfterCreateFromFront

func AfterCreateFromFront[Type Gongstruct](stage *StageStruct, instance *Type)

AfterCreateFromFront is called after a create from front

func AfterDeleteFromFront

func AfterDeleteFromFront[Type Gongstruct](stage *StageStruct, staged, front *Type)

AfterDeleteFromFront is called after a delete from front

func AfterReadFromFront

func AfterReadFromFront[Type Gongstruct](stage *StageStruct, instance *Type)

AfterReadFromFront is called after a Read from front

func AfterUpdateFromFront

func AfterUpdateFromFront[Type Gongstruct](stage *StageStruct, old, new *Type)

AfterUpdateFromFront is called after a update from front

func CompareGongstructByName

func CompareGongstructByName[T PointerToGongstruct](a, b T) int

func CopyBranch

func CopyBranch[Type Gongstruct](from *Type) (to *Type)

CopyBranch stages instance and apply CopyBranch on all gongstruct instances that are referenced by pointers or slices of pointers of the instance

the algorithm stops along the course of graph if a vertex is already staged

func EvictInOtherSlices

func EvictInOtherSlices[OwningType PointerToGongstruct, FieldType PointerToGongstruct](
	stage *StageStruct,
	owningInstance OwningType,
	sliceField []FieldType,
	fieldName string)

EvictInOtherSlices allows for adherance between the gong association model and go.

Says you have a Astruct struct with a slice field "anarrayofb []*Bstruct"

go allows many Astruct instance to have the anarrayofb field that have the same pointers. go slices are MANY-MANY association.

With gong it is only ZERO-ONE-MANY associations, a Bstruct can be pointed only once by an Astruct instance through a given field. This follows the requirement that gong is suited for full stack programming and therefore the association is encoded as a reverse pointer (not as a joint table). In gong, a named struct is translated in a table and each table is a named struct.

EvictInOtherSlices removes the fields instances from other fields of other instance

Note : algo is in O(N)log(N) of nb of Astruct and Bstruct instances

func GetAssociationName

func GetAssociationName[Type Gongstruct]() *Type

GetAssociationName is a generic function that returns an instance of Type where each association is filled with an instance whose name is the name of the association

This function can be handy for generating navigation function that are refactorable

func GetFieldStringValue

func GetFieldStringValue[Type Gongstruct](instance Type, fieldName string) (res string)

func GetFieldStringValueFromPointer

func GetFieldStringValueFromPointer[Type PointerToGongstruct](instance Type, fieldName string) (res string)

func GetFields

func GetFields[Type Gongstruct]() (res []string)

GetFields return the array of the fields

func GetFieldsFromPointer

func GetFieldsFromPointer[Type PointerToGongstruct]() (res []string)

GetFieldsFromPointer return the array of the fields

func GetGongstrucsSorted

func GetGongstrucsSorted[T PointerToGongstruct](stage *StageStruct) (sortedSlice []T)

func GetGongstructInstancesMap

func GetGongstructInstancesMap[Type Gongstruct](stage *StageStruct) *map[string]*Type

GetGongstructInstancesMap returns the map of staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func GetGongstructInstancesSet

func GetGongstructInstancesSet[Type Gongstruct](stage *StageStruct) *map[*Type]any

GetGongstructInstancesSet returns the set staged GongstructType instances it is usefull because it allows refactoring of gongstruct identifier

func GetGongstructInstancesSetFromPointerType

func GetGongstructInstancesSetFromPointerType[Type PointerToGongstruct](stage *StageStruct) *map[Type]any

GetGongstructInstancesSetFromPointerType returns the set staged GongstructType instances it is usefull because it allows refactoring of gongstruct identifier

func GetGongstructName

func GetGongstructName[Type Gongstruct]() (res string)

GetGongstructName returns the name of the Gongstruct this can be usefull if one want program robust to refactoring

func GetPointerReverseMap

func GetPointerReverseMap[Start, End Gongstruct](fieldname string, stage *StageStruct) map[*End][]*Start

GetPointerReverseMap allows backtrack navigation of any Start.Fieldname associations (0..1) that is a pointer from one staged Gongstruct (type Start) instances to another (type End)

The function provides a map with keys as instances of End and values to arrays of *Start the map is construed by iterating over all Start instances and populationg keys with End instances and values with slice of Start instances

func GetPointerToGongstructName

func GetPointerToGongstructName[Type PointerToGongstruct]() (res string)

GetPointerToGongstructName returns the name of the Gongstruct this can be usefull if one want program robust to refactoring

func GetSliceOfPointersReverseMap

func GetSliceOfPointersReverseMap[Start, End Gongstruct](fieldname string, stage *StageStruct) map[*End]*Start

GetSliceOfPointersReverseMap allows backtrack navigation of any Start.Fieldname associations (0..N) between one staged Gongstruct instances and many others

The function provides a map with keys as instances of End and values to *Start instances the map is construed by iterating over all Start instances and populating keys with End instances and values with the Start instances

func GongGetMap

func GongGetMap[Type GongstructMapString](stage *StageStruct) *Type

GongGetMap returns the map of staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func GongGetSet

func GongGetSet[Type GongstructSet](stage *StageStruct) *Type

GongGetSet returns the set staged GongstructType instances it is usefull because it allows refactoring of gong struct identifier

func IntToLetters

func IntToLetters(number int32) (letters string)

func IsStaged

func IsStaged[Type Gongstruct](stage *StageStruct, instance *Type) (ok bool)

func Min

func Min(x, y time.Duration) time.Duration

Min returns the larger of x or y.

func ParseAstFile

func ParseAstFile(stage *StageStruct, pathToFile string) error

ParseAstFile Parse pathToFile and stages all instances declared in the file

func ParseAstFileFromAst

func ParseAstFileFromAst(stage *StageStruct, inFile *ast.File, fset *token.FileSet) error

ParseAstFile Parse pathToFile and stages all instances declared in the file

func Serialize

func Serialize[Type Gongstruct](stage *StageStruct, tab Tabulator)

func SerializeExcelize

func SerializeExcelize[Type Gongstruct](stage *StageStruct, f *excelize.File)

func SerializeStage

func SerializeStage(stage *StageStruct, filename string)

func SetCallbackAfterCreateFromFront

func SetCallbackAfterCreateFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterCreateInterface[Type])

func SetCallbackAfterDeleteFromFront

func SetCallbackAfterDeleteFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterDeleteInterface[Type])

func SetCallbackAfterReadFromFront

func SetCallbackAfterReadFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterReadInterface[Type])

func SetCallbackAfterUpdateFromFront

func SetCallbackAfterUpdateFromFront[Type Gongstruct](stage *StageStruct, callback OnAfterUpdateInterface[Type])

SetCallbackAfterUpdateFromFront is a function to set up callback that is robust to refactoring

func SetOrchestratorOnAfterUpdate

func SetOrchestratorOnAfterUpdate[Type Gongstruct](stage *StageStruct)

func SortGongstructSetByName

func SortGongstructSetByName[T PointerToGongstruct](set map[T]any) (sortedSlice []T)

func StageBranch

func StageBranch[Type Gongstruct](stage *StageStruct, instance *Type)

StageBranch stages instance and apply StageBranch on all gongstruct instances that are referenced by pointers or slices of pointers of the instance

the algorithm stops along the course of graph if a vertex is already staged

func UnmarshallGongstructStaging

func UnmarshallGongstructStaging(stage *StageStruct, cmap *ast.CommentMap, assignStmt *ast.AssignStmt, astCoordinate_ string) (
	instance any,
	identifier string,
	gongstructName string,
	fieldName string)

UnmarshallGoStaging unmarshall a go assign statement

func UnstageBranch

func UnstageBranch[Type Gongstruct](stage *StageStruct, instance *Type)

UnstageBranch stages instance and apply UnstageBranch on all gongstruct instances that are referenced by pointers or slices of pointers of the insance

the algorithm stops along the course of graph if a vertex is already staged

Types

type Agent

type Agent struct {
	TechName string

	// usefull to append an agent to the Engine from an agent
	// swagger:ignore
	Engine *Engine
	// contains filtered or unexported fields
}

Agent is the empty struct to perform generic agents chores

func (*Agent) AppendAgentToEngine

func (agent *Agent) AppendAgentToEngine(newAgent AgentInterface)

AppendAgentToEngine append an agent to the engine

func (*Agent) Events

func (agent *Agent) Events() []EventInterface

Events append an agent to the engine

func (*Agent) GetNextEvent

func (agent *Agent) GetNextEvent() (EventInterface, time.Time)

GetNextEvent provides the next event from a time point of view by convention 0 means infinity

func (*Agent) GetNextEventAndRemoveIt

func (agent *Agent) GetNextEventAndRemoveIt() (event EventInterface, t time.Time)

GetNextEventAndRemoveIt provides the next event from a time point of view by convention 0 means infinity

func (*Agent) GetTechName

func (agent *Agent) GetTechName() string

Events append an agent to the engine

func (*Agent) QueueEvent

func (agent *Agent) QueueEvent(event EventInterface)

QueueEvent is the function by which an agent queues an event from another agent (or of himself)

func (*Agent) QueueUpdateEvent

func (agent *Agent) QueueUpdateEvent(engine *Engine, duration time.Duration) *Agent

QueueUpdateEvent put an UpdateState event with duration to the agent with fire time equals to EngineSingloton current time

return the agent

func (*Agent) RemoveAgentToEngine

func (agent *Agent) RemoveAgentToEngine(newAgent AgentInterface)

RemoveAgentToEngine append an agent to the engine

func (*Agent) Reset

func (agent *Agent) Reset()

Reset removes all events from the agent and resets internal checks

func (*Agent) SetEngine

func (agent *Agent) SetEngine(engine *Engine)

func (*Agent) TransfertAndQueueEvent

func (agent *Agent) TransfertAndQueueEvent(event EventInterface)

type AgentInterface

type AgentInterface interface {

	// GetNextEvent provides the event with earliest fire time
	GetNextEvent() (event EventInterface, time time.Time)

	// FireNextEvent fire next Event
	FireNextEvent()

	// Events fire next Event
	Events() []EventInterface

	SetEngine(engine *Engine)

	// Reset
	Reset()

	// get technical name
	GetTechName() string

	QueueEvent(event EventInterface)
	TransfertAndQueueEvent(event EventInterface)
}

AgentInterface is the interface that must be followed by part of the simulation swagger:model AgentInterface

func AppendToSingloton

func AppendToSingloton(engine *Engine, agent AgentInterface) AgentInterface

Implements the interface function

type AllModelsStructCreateInterface

type AllModelsStructCreateInterface interface {
	CreateORMDummyAgent(DummyAgent *DummyAgent)
	CreateORMEngine(Engine *Engine)
	CreateORMEvent(Event *Event)
	CreateORMGongsimCommand(GongsimCommand *GongsimCommand)
	CreateORMGongsimStatus(GongsimStatus *GongsimStatus)
}

swagger:ignore

type AllModelsStructDeleteInterface

type AllModelsStructDeleteInterface interface {
	DeleteORMDummyAgent(DummyAgent *DummyAgent)
	DeleteORMEngine(Engine *Engine)
	DeleteORMEvent(Event *Event)
	DeleteORMGongsimCommand(GongsimCommand *GongsimCommand)
	DeleteORMGongsimStatus(GongsimStatus *GongsimStatus)
}

type BackRepoInterface

type BackRepoInterface interface {
	Commit(stage *StageStruct)
	Checkout(stage *StageStruct)
	Backup(stage *StageStruct, dirPath string)
	Restore(stage *StageStruct, dirPath string)
	BackupXL(stage *StageStruct, dirPath string)
	RestoreXL(stage *StageStruct, dirPath string)
	// insertion point for Commit and Checkout signatures
	CommitDummyAgent(dummyagent *DummyAgent)
	CheckoutDummyAgent(dummyagent *DummyAgent)
	CommitEngine(engine *Engine)
	CheckoutEngine(engine *Engine)
	CommitEvent(event *Event)
	CheckoutEvent(event *Event)
	CommitGongsimCommand(gongsimcommand *GongsimCommand)
	CheckoutGongsimCommand(gongsimcommand *GongsimCommand)
	CommitGongsimStatus(gongsimstatus *GongsimStatus)
	CheckoutGongsimStatus(gongsimstatus *GongsimStatus)
	GetLastCommitFromBackNb() uint
	GetLastPushFromFrontNb() uint
}

type ControlMode

type ControlMode string

swagger:enum ControlMode

const (
	AUTONOMOUS     ControlMode = "Autonomous" // iota
	CLIENT_CONTROL ControlMode = "ClientControl"
)

values for ControlMode

func (ControlMode) CodeValues

func (controlmode ControlMode) CodeValues() (res []string)

func (ControlMode) Codes

func (controlmode ControlMode) Codes() (res []string)

func (*ControlMode) FromCodeString

func (controlmode *ControlMode) FromCodeString(input string) (err error)

func (*ControlMode) FromString

func (controlmode *ControlMode) FromString(input string) (err error)

func (*ControlMode) ToCodeString

func (controlmode *ControlMode) ToCodeString() (res string)

func (ControlMode) ToString

func (controlmode ControlMode) ToString() (res string)

insertion point of enum utility functions Utility function for ControlMode if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type DummyAgent

type DummyAgent struct {
	Agent

	Name string
}

func CopyBranchDummyAgent

func CopyBranchDummyAgent(mapOrigCopy map[any]any, dummyagentFrom *DummyAgent) (dummyagentTo *DummyAgent)

insertion point for stage branch per struct

func (*DummyAgent) Checkout

func (dummyagent *DummyAgent) Checkout(stage *StageStruct) *DummyAgent

Checkout dummyagent to the back repo (if it is already staged)

func (*DummyAgent) Commit

func (dummyagent *DummyAgent) Commit(stage *StageStruct) *DummyAgent

commit dummyagent to the back repo (if it is already staged)

func (*DummyAgent) CommitVoid

func (dummyagent *DummyAgent) CommitVoid(stage *StageStruct)

func (*DummyAgent) CopyBasicFields

func (from *DummyAgent) CopyBasicFields(to *DummyAgent)

func (*DummyAgent) FireNextEvent

func (dummyAgent *DummyAgent) FireNextEvent()

func (*DummyAgent) GetName

func (dummyagent *DummyAgent) GetName() (res string)

for satisfaction of GongStruct interface

func (*DummyAgent) Stage

func (dummyagent *DummyAgent) Stage(stage *StageStruct) *DummyAgent

insertion point for cumulative sub template with model space calls Stage puts dummyagent to the model stage

func (*DummyAgent) Unstage

func (dummyagent *DummyAgent) Unstage(stage *StageStruct) *DummyAgent

Unstage removes dummyagent off the model stage

func (*DummyAgent) UnstageVoid

func (dummyagent *DummyAgent) UnstageVoid(stage *StageStruct)

UnstageVoid removes dummyagent off the model stage

type DummyAgent_WOP

type DummyAgent_WOP struct {
	// insertion point
	TechName string
	Name     string
}

insertion point

type Engine

type Engine struct {
	// Name of the engine "laundramat" for instance
	Name string

	EndTime string

	CurrentTime string

	// number of the seconds elapsed since the beginning of the simulation
	SecondsSinceStart float64

	// Fired events
	Fired int

	// control mode.
	ControlMode ControlMode

	// engine state
	State EngineState

	// LastEvent ...
	LastEvent *EventInterface `gorm:"-"`

	// LastEvent agent
	LastEventAgent *AgentInterface `gorm:"-"`

	// Simulation supportspecific callback
	// on the engine events
	Simulation SimulationInterface `gorm:"-"`

	// Speed compared to realtime
	Speed float64
	// contains filtered or unexported fields
}

Engine describes a tiny discrete event simulation engine it is responsible for advancing the time An engine manages a set of agents swagger:model Engine

func CopyBranchEngine

func CopyBranchEngine(mapOrigCopy map[any]any, engineFrom *Engine) (engineTo *Engine)

func (*Engine) Agents

func (engine *Engine) Agents() (agents []AgentInterface)

func (*Engine) AppendAgent

func (engine *Engine) AppendAgent(agent AgentInterface)

AppendAgent to the engine

func (*Engine) Checkout

func (engine *Engine) Checkout(stage *StageStruct) *Engine

Checkout engine to the back repo (if it is already staged)

func (*Engine) Commit

func (engine *Engine) Commit(stage *StageStruct) *Engine

commit engine to the back repo (if it is already staged)

func (*Engine) CommitVoid

func (engine *Engine) CommitVoid(stage *StageStruct)

func (*Engine) CopyBasicFields

func (from *Engine) CopyBasicFields(to *Engine)

func (*Engine) FireNextEvent

func (engine *Engine) FireNextEvent() (agent AgentInterface, nextTimeEvent time.Time, event EventInterface)

FireNextEvent fires earliest event advances current time

func (*Engine) GetCurrentTime

func (engine *Engine) GetCurrentTime() time.Time

func (*Engine) GetEndTime

func (engine *Engine) GetEndTime() time.Time

func (*Engine) GetLastCommitNb

func (engine *Engine) GetLastCommitNb() (commitNb uint)

func (*Engine) GetLastCommitNbFromFront

func (engine *Engine) GetLastCommitNbFromFront() (commitNb uint)

func (*Engine) GetName

func (engine *Engine) GetName() (res string)

for satisfaction of GongStruct interface

func (*Engine) GetNextEvent

func (engine *Engine) GetNextEvent() (agent AgentInterface, nextEventFireTime time.Time, event EventInterface)

GetNextEvent ...

func (*Engine) GetStartTime

func (engine *Engine) GetStartTime() time.Time

func (*Engine) ListEvents

func (engine *Engine) ListEvents()

ListEvents

func (*Engine) RemoveAgent

func (engine *Engine) RemoveAgent(agent AgentInterface)

RemoveAgent to the engine

func (*Engine) Run

func (engine *Engine) Run()

Run will advance time till currentTime > EndTime

func (*Engine) RunTillAnyStateHasChanged

func (engine *Engine) RunTillAnyStateHasChanged()

RunTillAnyStateHasChanged will advance time till currentTime > EndTime or one state Changed in the implementation

func (*Engine) SetCurrentTime

func (engine *Engine) SetCurrentTime(time time.Time)

func (*Engine) SetEndTime

func (engine *Engine) SetEndTime(time time.Time)

func (*Engine) SetStartTime

func (engine *Engine) SetStartTime(time time.Time)

func (*Engine) Stage

func (engine *Engine) Stage(stage *StageStruct) *Engine

Stage puts engine to the model stage

func (*Engine) Unstage

func (engine *Engine) Unstage(stage *StageStruct) *Engine

Unstage removes engine off the model stage

func (*Engine) UnstageVoid

func (engine *Engine) UnstageVoid(stage *StageStruct)

UnstageVoid removes engine off the model stage

type EngineDriverState

type EngineDriverState int

the states of the engine drivers

const (
	COMMIT_AGENT_STATES EngineDriverState = iota
	CHECKOUT_AGENT_STATES
	FIRE_ONE_EVENT
	SLEEP_100_MS
	RESET_SIMULATION
	UNKOWN
)

func (EngineDriverState) CodeValues

func (enginedriverstate EngineDriverState) CodeValues() (res []int)

func (EngineDriverState) Codes

func (enginedriverstate EngineDriverState) Codes() (res []string)

func (*EngineDriverState) FromCodeString

func (enginedriverstate *EngineDriverState) FromCodeString(input string) (err error)

func (*EngineDriverState) FromInt

func (enginedriverstate *EngineDriverState) FromInt(input int) (err error)

func (*EngineDriverState) ToCodeString

func (enginedriverstate *EngineDriverState) ToCodeString() (res string)

func (EngineDriverState) ToInt

func (enginedriverstate EngineDriverState) ToInt() (res int)

Utility function for EngineDriverState if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type EngineRunMode

type EngineRunMode int

the simulation can run with a relative speed to realtime or full speed

const (
	RELATIVE_SPEED EngineRunMode = iota
	FULL_SPEED
)

func (EngineRunMode) CodeValues

func (enginerunmode EngineRunMode) CodeValues() (res []int)

func (EngineRunMode) Codes

func (enginerunmode EngineRunMode) Codes() (res []string)

func (*EngineRunMode) FromCodeString

func (enginerunmode *EngineRunMode) FromCodeString(input string) (err error)

func (*EngineRunMode) FromInt

func (enginerunmode *EngineRunMode) FromInt(input int) (err error)

func (*EngineRunMode) ToCodeString

func (enginerunmode *EngineRunMode) ToCodeString() (res string)

func (EngineRunMode) ToInt

func (enginerunmode EngineRunMode) ToInt() (res int)

Utility function for EngineRunMode if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type EngineState

type EngineState string

swagger:enum EngineState

const (
	RUNNING EngineState = "RUNNING" // iota
	PAUSED  EngineState = "PAUSED"
	OVER    EngineState = "OVER"
)

values for EngineState

func (EngineState) CodeValues

func (enginestate EngineState) CodeValues() (res []string)

func (EngineState) Codes

func (enginestate EngineState) Codes() (res []string)

func (*EngineState) FromCodeString

func (enginestate *EngineState) FromCodeString(input string) (err error)

func (*EngineState) FromString

func (enginestate *EngineState) FromString(input string) (err error)

func (*EngineState) ToCodeString

func (enginestate *EngineState) ToCodeString() (res string)

func (EngineState) ToString

func (enginestate EngineState) ToString() (res string)

Utility function for EngineState if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type EngineStopMode

type EngineStopMode int
const (
	TEN_MINUTES EngineStopMode = iota
	STATE_CHANGED
)

func (EngineStopMode) CodeValues

func (enginestopmode EngineStopMode) CodeValues() (res []int)

func (EngineStopMode) Codes

func (enginestopmode EngineStopMode) Codes() (res []string)

func (*EngineStopMode) FromCodeString

func (enginestopmode *EngineStopMode) FromCodeString(input string) (err error)

func (*EngineStopMode) FromInt

func (enginestopmode *EngineStopMode) FromInt(input int) (err error)

func (*EngineStopMode) ToCodeString

func (enginestopmode *EngineStopMode) ToCodeString() (res string)

func (EngineStopMode) ToInt

func (enginestopmode EngineStopMode) ToInt() (res int)

Utility function for EngineStopMode if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type Engine_WOP

type Engine_WOP struct {
	// insertion point
	Name              string
	EndTime           string
	CurrentTime       string
	SecondsSinceStart float64
	Fired             int
	ControlMode       ControlMode
	State             EngineState
	Speed             float64
}

type Event

type Event struct {
	Name string

	// Duration is the difference between the current time and the fire time of the
	// event. It is handy to compute directly the fire time
	Duration time.Duration
	// contains filtered or unexported fields
}

Event is the elementary element of a discrete event simulation swagger:model Event

func CopyBranchEvent

func CopyBranchEvent(mapOrigCopy map[any]any, eventFrom *Event) (eventTo *Event)

func (*Event) Checkout

func (event *Event) Checkout(stage *StageStruct) *Event

Checkout event to the back repo (if it is already staged)

func (*Event) Commit

func (event *Event) Commit(stage *StageStruct) *Event

commit event to the back repo (if it is already staged)

func (*Event) CommitVoid

func (event *Event) CommitVoid(stage *StageStruct)

func (*Event) CopyBasicFields

func (from *Event) CopyBasicFields(to *Event)

func (*Event) GetAgent

func (event *Event) GetAgent() *Agent

func (*Event) GetDuration

func (event *Event) GetDuration() time.Duration

GetDuration ...

func (*Event) GetFireTime

func (event *Event) GetFireTime() time.Time

GetFireTime ...

func (*Event) GetName

func (event *Event) GetName() (res string)

for satisfaction of GongStruct interface

func (*Event) SetAgent

func (event *Event) SetAgent(agent *Agent)

func (*Event) SetFireTime

func (event *Event) SetFireTime(t time.Time)

func (*Event) Stage

func (event *Event) Stage(stage *StageStruct) *Event

Stage puts event to the model stage

func (*Event) Unstage

func (event *Event) Unstage(stage *StageStruct) *Event

Unstage removes event off the model stage

func (*Event) UnstageVoid

func (event *Event) UnstageVoid(stage *StageStruct)

UnstageVoid removes event off the model stage

type EventInterface

type EventInterface interface {
	GetFireTime() time.Time
	SetFireTime(time.Time)
	GetDuration() time.Duration
	GetName() string
	SetAgent(agent *Agent)
	GetAgent() *Agent
}

EventInterface ... swagger:ignore

type Event_WOP

type Event_WOP struct {
	// insertion point
	Name     string
	Duration time.Duration
}

type ExcelizeTabulator

type ExcelizeTabulator struct {
	// contains filtered or unexported fields
}

func (*ExcelizeTabulator) AddCell

func (tab *ExcelizeTabulator) AddCell(sheetName string, rowId, columnIndex int, value string)

func (*ExcelizeTabulator) AddRow

func (tab *ExcelizeTabulator) AddRow(sheetName string) (rowId int)

func (*ExcelizeTabulator) AddSheet

func (tab *ExcelizeTabulator) AddSheet(sheetName string)

func (*ExcelizeTabulator) SetExcelizeFile

func (tab *ExcelizeTabulator) SetExcelizeFile(f *excelize.File)

type GONG__ExpressionType

type GONG__ExpressionType string

swagger:ignore

const (
	GONG__STRUCT_INSTANCE      GONG__ExpressionType = "STRUCT_INSTANCE"
	GONG__FIELD_OR_CONST_VALUE GONG__ExpressionType = "FIELD_OR_CONST_VALUE"
	GONG__FIELD_VALUE          GONG__ExpressionType = "FIELD_VALUE"
	GONG__ENUM_CAST_INT        GONG__ExpressionType = "ENUM_CAST_INT"
	GONG__ENUM_CAST_STRING     GONG__ExpressionType = "ENUM_CAST_STRING"
	GONG__IDENTIFIER_CONST     GONG__ExpressionType = "IDENTIFIER_CONST"
)

type GONG__Identifier

type GONG__Identifier struct {
	Ident string
	Type  GONG__ExpressionType
}

type GongStructInterface

type GongStructInterface interface {
	GetName() (res string)
}

GongStructInterface is the interface met by GongStructs It allows runtime reflexion of instances (without the hassle of the "reflect" package)

type GongsimCommand

type GongsimCommand struct {
	Name             string
	Command          GongsimCommandType
	CommandDate      string
	SpeedCommandType SpeedCommandType
	DateSpeedCommand string
	Engine           *Engine
	// contains filtered or unexported fields
}

GongsimCommand is the struct of the instance that is updated by the front for issuing commands swagger:model GongsimCommand

func CopyBranchGongsimCommand

func CopyBranchGongsimCommand(mapOrigCopy map[any]any, gongsimcommandFrom *GongsimCommand) (gongsimcommandTo *GongsimCommand)

func NewGongSimCommand

func NewGongSimCommand(stage *StageStruct, engine *Engine) (gongsimCommand *GongsimCommand)

func (*GongsimCommand) Checkout

func (gongsimcommand *GongsimCommand) Checkout(stage *StageStruct) *GongsimCommand

Checkout gongsimcommand to the back repo (if it is already staged)

func (*GongsimCommand) Commit

func (gongsimcommand *GongsimCommand) Commit(stage *StageStruct) *GongsimCommand

commit gongsimcommand to the back repo (if it is already staged)

func (*GongsimCommand) CommitVoid

func (gongsimcommand *GongsimCommand) CommitVoid(stage *StageStruct)

func (*GongsimCommand) CopyBasicFields

func (from *GongsimCommand) CopyBasicFields(to *GongsimCommand)

func (*GongsimCommand) GetName

func (gongsimcommand *GongsimCommand) GetName() (res string)

for satisfaction of GongStruct interface

func (*GongsimCommand) SetupGongsimThreads

func (gongsimCommand *GongsimCommand) SetupGongsimThreads() *GongsimCommand

SetupGongsimThreads schedules gongsim threads

func (*GongsimCommand) Stage

func (gongsimcommand *GongsimCommand) Stage(stage *StageStruct) *GongsimCommand

Stage puts gongsimcommand to the model stage

func (*GongsimCommand) Unstage

func (gongsimcommand *GongsimCommand) Unstage(stage *StageStruct) *GongsimCommand

Unstage removes gongsimcommand off the model stage

func (*GongsimCommand) UnstageVoid

func (gongsimcommand *GongsimCommand) UnstageVoid(stage *StageStruct)

UnstageVoid removes gongsimcommand off the model stage

type GongsimCommandType

type GongsimCommandType string

swagger:enum GongsimCommandType

const (
	COMMAND_PLAY                          GongsimCommandType = "PLAY"
	COMMAND_PAUSE                         GongsimCommandType = "PAUSE"
	COMMAND_FIRE_NEXT_EVENT               GongsimCommandType = "FIRE_NEXT_EVENT"
	COMMAND_FIRE_EVENT_TILL_STATES_CHANGE GongsimCommandType = "FIRE_EVENT_TILL_STATES_CHANGE"
	COMMAND_RESET                         GongsimCommandType = "RESET"
	COMMAND_ADVANCE_10_MIN                GongsimCommandType = "ADVANCE_10_MIN"
)

values for EnumType

func (GongsimCommandType) CodeValues

func (gongsimcommandtype GongsimCommandType) CodeValues() (res []string)

func (GongsimCommandType) Codes

func (gongsimcommandtype GongsimCommandType) Codes() (res []string)

func (*GongsimCommandType) FromCodeString

func (gongsimcommandtype *GongsimCommandType) FromCodeString(input string) (err error)

func (*GongsimCommandType) FromString

func (gongsimcommandtype *GongsimCommandType) FromString(input string) (err error)

func (*GongsimCommandType) ToCodeString

func (gongsimcommandtype *GongsimCommandType) ToCodeString() (res string)

func (GongsimCommandType) ToString

func (gongsimcommandtype GongsimCommandType) ToString() (res string)

Utility function for GongsimCommandType if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type GongsimCommand_WOP

type GongsimCommand_WOP struct {
	// insertion point
	Name             string
	Command          GongsimCommandType
	CommandDate      string
	SpeedCommandType SpeedCommandType
	DateSpeedCommand string
}

type GongsimStatus

type GongsimStatus struct {
	Name                       string
	CurrentCommand             GongsimCommandType
	CompletionDate             string
	CurrentSpeedCommand        SpeedCommandType
	SpeedCommandCompletionDate string
}

GongsimStatus is the struct of the instance that is updated by the front for issuing Statuss swagger:model GongsimStatus

func CopyBranchGongsimStatus

func CopyBranchGongsimStatus(mapOrigCopy map[any]any, gongsimstatusFrom *GongsimStatus) (gongsimstatusTo *GongsimStatus)

func (*GongsimStatus) Checkout

func (gongsimstatus *GongsimStatus) Checkout(stage *StageStruct) *GongsimStatus

Checkout gongsimstatus to the back repo (if it is already staged)

func (*GongsimStatus) Commit

func (gongsimstatus *GongsimStatus) Commit(stage *StageStruct) *GongsimStatus

commit gongsimstatus to the back repo (if it is already staged)

func (*GongsimStatus) CommitVoid

func (gongsimstatus *GongsimStatus) CommitVoid(stage *StageStruct)

func (*GongsimStatus) CopyBasicFields

func (from *GongsimStatus) CopyBasicFields(to *GongsimStatus)

func (*GongsimStatus) GetName

func (gongsimstatus *GongsimStatus) GetName() (res string)

for satisfaction of GongStruct interface

func (*GongsimStatus) Stage

func (gongsimstatus *GongsimStatus) Stage(stage *StageStruct) *GongsimStatus

Stage puts gongsimstatus to the model stage

func (*GongsimStatus) Unstage

func (gongsimstatus *GongsimStatus) Unstage(stage *StageStruct) *GongsimStatus

Unstage removes gongsimstatus off the model stage

func (*GongsimStatus) UnstageVoid

func (gongsimstatus *GongsimStatus) UnstageVoid(stage *StageStruct)

UnstageVoid removes gongsimstatus off the model stage

type GongsimStatus_WOP

type GongsimStatus_WOP struct {
	// insertion point
	Name                       string
	CurrentCommand             GongsimCommandType
	CompletionDate             string
	CurrentSpeedCommand        SpeedCommandType
	SpeedCommandCompletionDate string
}

type Gongstruct

type Gongstruct interface {
	// insertion point for generic types
	DummyAgent | Engine | Event | GongsimCommand | GongsimStatus
}

Gongstruct is the type parameter for generated generic function that allows - access to staged instances - navigation between staged instances by going backward association links between gongstruct - full refactoring of Gongstruct identifiers / fields

type GongstructEnumIntField

type GongstructEnumIntField interface {
	int | EngineDriverState | EngineRunMode | EngineStopMode
	Codes() []string
	CodeValues() []int
}

type GongstructEnumStringField

type GongstructEnumStringField interface {
	string | ControlMode | EngineState | GongsimCommandType | SpeedCommandType
	Codes() []string
	CodeValues() []string
}

type GongstructMapString

type GongstructMapString interface {
	map[any]any |

		map[string]*DummyAgent |
		map[string]*Engine |
		map[string]*Event |
		map[string]*GongsimCommand |
		map[string]*GongsimStatus |
		map[*any]any // because go does not support an extra "|" at the end of type specifications
}

type GongstructSet

type GongstructSet interface {
	map[any]any |

		map[*DummyAgent]any |
		map[*Engine]any |
		map[*Event]any |
		map[*GongsimCommand]any |
		map[*GongsimStatus]any |
		map[*any]any // because go does not support an extra "|" at the end of type specifications
}

type GongtructBasicField

type GongtructBasicField interface {
	int | float64 | bool | string | time.Time | time.Duration
}

type OnAfterCreateInterface

type OnAfterCreateInterface[Type Gongstruct] interface {
	OnAfterCreate(stage *StageStruct,
		instance *Type)
}

OnAfterCreateInterface callback when an instance is updated from the front

type OnAfterDeleteInterface

type OnAfterDeleteInterface[Type Gongstruct] interface {
	OnAfterDelete(stage *StageStruct,
		staged, front *Type)
}

OnAfterDeleteInterface callback when an instance is updated from the front

type OnAfterReadInterface

type OnAfterReadInterface[Type Gongstruct] interface {
	OnAfterRead(stage *StageStruct,
		instance *Type)
}

OnAfterReadInterface callback when an instance is updated from the front

type OnAfterUpdateInterface

type OnAfterUpdateInterface[Type Gongstruct] interface {
	OnAfterUpdate(stage *StageStruct, old, new *Type)
}

OnAfterUpdateInterface callback when an instance is updated from the front

type OnInitCommitInterface

type OnInitCommitInterface interface {
	BeforeCommit(stage *StageStruct)
}

type PointerToGongstruct

type PointerToGongstruct interface {
	*DummyAgent | *Engine | *Event | *GongsimCommand | *GongsimStatus
	GetName() string
	CommitVoid(*StageStruct)
	UnstageVoid(stage *StageStruct)
}

Gongstruct is the type parameter for generated generic function that allows - access to staged instances - navigation between staged instances by going backward association links between gongstruct - full refactoring of Gongstruct identifiers / fields

type PointerToGongstructEnumIntField

type PointerToGongstructEnumIntField interface {
	*EngineDriverState | *EngineRunMode | *EngineStopMode
	FromCodeString(input string) (err error)
}

type PointerToGongstructEnumStringField

type PointerToGongstructEnumStringField interface {
	*ControlMode | *EngineState | *GongsimCommandType | *SpeedCommandType
	FromCodeString(input string) (err error)
}

type ReverseField

type ReverseField struct {
	GongstructName string
	Fieldname      string
}

func GetReverseFields

func GetReverseFields[Type Gongstruct]() (res []ReverseField)

type Simulation

type Simulation struct {
	DB *gorm.DB
}

the simplest possible simulation

func (*Simulation) CheckoutAgents

func (specificEngine *Simulation) CheckoutAgents(engine *Engine)

func (*Simulation) CommitAgents

func (specificEngine *Simulation) CommitAgents(engine *Engine)

func (*Simulation) EventFired

func (specificEngine *Simulation) EventFired(engine *Engine)

func (*Simulation) GetLastCommitNb

func (specificEngine *Simulation) GetLastCommitNb() uint

func (*Simulation) GetLastCommitNbFromFront

func (specificEngine *Simulation) GetLastCommitNbFromFront() uint

func (*Simulation) HasAnyStateChanged

func (specificEngine *Simulation) HasAnyStateChanged(engine *Engine) bool

func (*Simulation) Reset

func (specificEngine *Simulation) Reset(engine *Engine)

type SimulationInterface

type SimulationInterface interface {

	// HasAnyStateChanged provides the generic engine infos about the behavior
	// of simulation
	//
	// It is used in order to have the "advance till one state changes" call
	//
	// the simulation shall implement this callback
	// it returns true if one state of the specific has changed
	HasAnyStateChanged(engine *Engine) bool

	// CommitAgents requests the simulation to commit the instances values to the back repo
	//
	// This is used when the simulation states has to be read by an outside component (the front component for instance)
	CommitAgents(engines *Engine)

	// CheckoutAgents requests the simulation to checkout the instances values from the back repo
	//
	// This is used when the simulation states has to be updated by values set by an outside component (the front component for instance)
	CheckoutAgents(engine *Engine)

	// GetLastCommitNb fetch the last commit nb from the simulation
	// this enables the engine to compute when it is necessary to update the stage following
	// updates to the back repo from the front
	GetLastCommitNb() uint

	// GetLastCommitNbFromFront fetch the last commit nb from the front to the simulation
	GetLastCommitNbFromFront() uint

	// Reset simulation
	Reset(engine *Engine)
}

SimulationInterface is the callback support for events that happens on the generic engine

type SpeedCommandType

type SpeedCommandType string

swagger:enum GongsimCommandType

const (
	COMMAND_INCREASE_SPEED_100_PERCENTS SpeedCommandType = "INCREASE_SPEED_100_PERCENTS"
	COMMAND_DECREASE_SPEED_50_PERCENTS  SpeedCommandType = "COMMAND_DECREASE_SPEED_50_PERCENTS "
	COMMAND_SPEED_STEADY                SpeedCommandType = "COMMAND_SPEED_STEADY"
)

func (SpeedCommandType) CodeValues

func (speedcommandtype SpeedCommandType) CodeValues() (res []string)

func (SpeedCommandType) Codes

func (speedcommandtype SpeedCommandType) Codes() (res []string)

func (*SpeedCommandType) FromCodeString

func (speedcommandtype *SpeedCommandType) FromCodeString(input string) (err error)

func (*SpeedCommandType) FromString

func (speedcommandtype *SpeedCommandType) FromString(input string) (err error)

func (*SpeedCommandType) ToCodeString

func (speedcommandtype *SpeedCommandType) ToCodeString() (res string)

func (SpeedCommandType) ToString

func (speedcommandtype SpeedCommandType) ToString() (res string)

Utility function for SpeedCommandType if enum values are string, it is stored with the value if enum values are int, they are stored with the code of the value

type StageStruct

type StageStruct struct {

	// insertion point for definition of arrays registering instances
	DummyAgents           map[*DummyAgent]any
	DummyAgents_mapString map[string]*DummyAgent

	OnAfterDummyAgentCreateCallback OnAfterCreateInterface[DummyAgent]
	OnAfterDummyAgentUpdateCallback OnAfterUpdateInterface[DummyAgent]
	OnAfterDummyAgentDeleteCallback OnAfterDeleteInterface[DummyAgent]
	OnAfterDummyAgentReadCallback   OnAfterReadInterface[DummyAgent]

	Engines           map[*Engine]any
	Engines_mapString map[string]*Engine

	OnAfterEngineCreateCallback OnAfterCreateInterface[Engine]
	OnAfterEngineUpdateCallback OnAfterUpdateInterface[Engine]
	OnAfterEngineDeleteCallback OnAfterDeleteInterface[Engine]
	OnAfterEngineReadCallback   OnAfterReadInterface[Engine]

	Events           map[*Event]any
	Events_mapString map[string]*Event

	OnAfterEventCreateCallback OnAfterCreateInterface[Event]
	OnAfterEventUpdateCallback OnAfterUpdateInterface[Event]
	OnAfterEventDeleteCallback OnAfterDeleteInterface[Event]
	OnAfterEventReadCallback   OnAfterReadInterface[Event]

	GongsimCommands           map[*GongsimCommand]any
	GongsimCommands_mapString map[string]*GongsimCommand

	OnAfterGongsimCommandCreateCallback OnAfterCreateInterface[GongsimCommand]
	OnAfterGongsimCommandUpdateCallback OnAfterUpdateInterface[GongsimCommand]
	OnAfterGongsimCommandDeleteCallback OnAfterDeleteInterface[GongsimCommand]
	OnAfterGongsimCommandReadCallback   OnAfterReadInterface[GongsimCommand]

	GongsimStatuss           map[*GongsimStatus]any
	GongsimStatuss_mapString map[string]*GongsimStatus

	OnAfterGongsimStatusCreateCallback OnAfterCreateInterface[GongsimStatus]
	OnAfterGongsimStatusUpdateCallback OnAfterUpdateInterface[GongsimStatus]
	OnAfterGongsimStatusDeleteCallback OnAfterDeleteInterface[GongsimStatus]
	OnAfterGongsimStatusReadCallback   OnAfterReadInterface[GongsimStatus]

	AllModelsStructCreateCallback AllModelsStructCreateInterface

	AllModelsStructDeleteCallback AllModelsStructDeleteInterface

	BackRepo BackRepoInterface

	// if set will be called before each commit to the back repo
	OnInitCommitCallback          OnInitCommitInterface
	OnInitCommitFromFrontCallback OnInitCommitInterface
	OnInitCommitFromBackCallback  OnInitCommitInterface

	// store the number of instance per gongstruct
	Map_GongStructName_InstancesNb map[string]int

	// store meta package import
	MetaPackageImportPath  string
	MetaPackageImportAlias string

	// to be removed after fix of [issue](https://github.com/golang/go/issues/57559)
	// map to enable docLink renaming when an identifier is renamed
	Map_DocLink_Renaming map[string]GONG__Identifier
	// contains filtered or unexported fields
}

StageStruct enables storage of staged instances swagger:ignore

func NewStage

func NewStage(path string) (stage *StageStruct)

func (*StageStruct) Backup

func (stage *StageStruct) Backup(dirPath string)

backup generates backup files in the dirPath

func (*StageStruct) BackupXL

func (stage *StageStruct) BackupXL(dirPath string)

backup generates backup files in the dirPath

func (*StageStruct) Checkout

func (stage *StageStruct) Checkout()

func (*StageStruct) Commit

func (stage *StageStruct) Commit()

func (*StageStruct) CommitWithSuspendedCallbacks

func (stage *StageStruct) CommitWithSuspendedCallbacks()

func (*StageStruct) ComputeReverseMaps

func (stage *StageStruct) ComputeReverseMaps()

ComputeReverseMaps computes the reverse map, for all intances, for all slice to pointers field Its complexity is in O(n)O(p) where p is the number of pointers

func (*StageStruct) GetPath

func (stage *StageStruct) GetPath() string

func (*StageStruct) GetType

func (stage *StageStruct) GetType() string

func (*StageStruct) IsStagedDummyAgent

func (stage *StageStruct) IsStagedDummyAgent(dummyagent *DummyAgent) (ok bool)

insertion point for stage per struct

func (*StageStruct) IsStagedEngine

func (stage *StageStruct) IsStagedEngine(engine *Engine) (ok bool)

func (*StageStruct) IsStagedEvent

func (stage *StageStruct) IsStagedEvent(event *Event) (ok bool)

func (*StageStruct) IsStagedGongsimCommand

func (stage *StageStruct) IsStagedGongsimCommand(gongsimcommand *GongsimCommand) (ok bool)

func (*StageStruct) IsStagedGongsimStatus

func (stage *StageStruct) IsStagedGongsimStatus(gongsimstatus *GongsimStatus) (ok bool)

func (*StageStruct) Marshall

func (stage *StageStruct) Marshall(file *os.File, modelsPackageName, packageName string)

Marshall marshall the stage content into the file as an instanciation into a stage

func (*StageStruct) Nil

func (stage *StageStruct) Nil()

func (*StageStruct) Reset

func (stage *StageStruct) Reset()

func (*StageStruct) Restore

func (stage *StageStruct) Restore(dirPath string)

Restore resets Stage & BackRepo and restores their content from the restore files in dirPath

func (*StageStruct) RestoreXL

func (stage *StageStruct) RestoreXL(dirPath string)

Restore resets Stage & BackRepo and restores their content from the restore files in dirPath

func (*StageStruct) StageBranchDummyAgent

func (stage *StageStruct) StageBranchDummyAgent(dummyagent *DummyAgent)

insertion point for stage branch per struct

func (*StageStruct) StageBranchEngine

func (stage *StageStruct) StageBranchEngine(engine *Engine)

func (*StageStruct) StageBranchEvent

func (stage *StageStruct) StageBranchEvent(event *Event)

func (*StageStruct) StageBranchGongsimCommand

func (stage *StageStruct) StageBranchGongsimCommand(gongsimcommand *GongsimCommand)

func (*StageStruct) StageBranchGongsimStatus

func (stage *StageStruct) StageBranchGongsimStatus(gongsimstatus *GongsimStatus)

func (*StageStruct) Unstage

func (stage *StageStruct) Unstage()

func (*StageStruct) UnstageBranchDummyAgent

func (stage *StageStruct) UnstageBranchDummyAgent(dummyagent *DummyAgent)

insertion point for unstage branch per struct

func (*StageStruct) UnstageBranchEngine

func (stage *StageStruct) UnstageBranchEngine(engine *Engine)

func (*StageStruct) UnstageBranchEvent

func (stage *StageStruct) UnstageBranchEvent(event *Event)

func (*StageStruct) UnstageBranchGongsimCommand

func (stage *StageStruct) UnstageBranchGongsimCommand(gongsimcommand *GongsimCommand)

func (*StageStruct) UnstageBranchGongsimStatus

func (stage *StageStruct) UnstageBranchGongsimStatus(gongsimstatus *GongsimStatus)

type Tabulator

type Tabulator interface {
	AddSheet(sheetName string)
	AddRow(sheetName string) int
	AddCell(sheetName string, rowId, columnIndex int, value string)
}

Tabulator is an interface for writing to a table strings

type UpdateState

type UpdateState struct {
	Event

	// Period is the time between two fires of FireTime
	Period time.Duration
}

UpdateState is an event whose role is to ask the agant to compute its new vector state swagger:model UpdateState

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL