Documentation
¶
Overview ¶
Example ¶
// create one consumer running for 10 minutes // every morning at 07.00 with power of 1000 W c, err := NewCronConsumer(CronConsumer{ Power: 1000, Duration: time.Minute * 10, Sched: "30 7 * * *", Description: "Hair dryer", }) if err != nil { panic(err) } ctx := context.TODO() // run the simulation from 2022-01-01 to 2022-01-02 ch := RunSim(ctx, Options{ Consumers: []Consumer{c}, StartTime: time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC), EndTime: time.Date(2022, 1, 2, 0, 0, 0, 0, time.UTC), Dt: time.Second, }) e := 0 // read the output from the simulation as it progresses for r := range ch { // fmt.Println(r.T) // this will be the current time in the simulation // fmt.Println(r.P) // this will be the current power at time T in the simulation // fmt.Println(r.E) // this will be the accumulated energy consumption over the simulation e = r.E } fmt.Println(e)
Output: 600000
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Consumer ¶
type Consumer interface { GetDescription() string GetPower(e Environment) int }
type CronConsumer ¶
type CronConsumer struct { Power int Sched string Duration time.Duration Description string CronShed cron.Schedule // contains filtered or unexported fields }
func NewCronConsumer ¶
func NewCronConsumer(c CronConsumer) (*CronConsumer, error)
NewCronConsumer return's a new cron consumer. The cron schedule specifies when the consumer is turned on. Cron schedule syntax "minute hour dayOfMonth month dayOfWeek" The duration determines how long the consumer in on and the power deterines the consumers constant power.
func (*CronConsumer) GetDescription ¶
func (s *CronConsumer) GetDescription() string
func (*CronConsumer) GetPower ¶
func (s *CronConsumer) GetPower(e Environment) int
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.