models

package
v0.0.0-...-be61b1a Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileType

func FileType(fl validator.FieldLevel) bool

func MountingSystemValidator

func MountingSystemValidator(fl validator.FieldLevel) bool

// Custom validation function for 'mounting_system'

Types

type Coordinates

type Coordinates struct {
	Latitude  float64 `bson:"latitude" json:"latitude" unique:"false"`
	Longitude float64 `bson:"longitude" json:"longitude" unique:"false"`
}

Coordinates represents a pair of latitude and longitude.

type File

type File struct {
	ID           primitive.ObjectID `bson:"_id,omitempty"`
	PublicFileID string             `bson:"public_file_id" json:"public_file_id" validate:"required" unique:"true"`
	Name         string             `bson:"name" json:"name" validate:"required,max=130" unique:"false"`
	Slug         string             `bson:"slug" json:"slug" validate:"required,max=130" unique:"true"`
	Type         string             `bson:"type" json:"type" validate:"required"` // file type (.jpeg, .png, .pdf)
	User         primitive.ObjectID `bson:"user_id"`                              // _id of user who owns/uploaded this file
	Size         int                `bson:"size" json:"size"  validate:"required" unique:"false"`
	Width        int                `bson:"width" json:"width"  validate:"required" unique:"false"`
	Height       int                `bson:"height" json:"height"  validate:"required" unique:"false"`
	Folder       string             `bson:"folder" validate:"required" unique:"false"` // folder in bucket
	CreatedAt    time.Time          `bson:"created_at" json:"created_at" validate:"required"`
}

type PhotovoltaicPlant

type PhotovoltaicPlant struct {
	ID             primitive.ObjectID `bson:"_id,omitempty"`          // Same _id as in PlantLoggerConfig
	User           primitive.ObjectID `bson:"user_id" unique:"false"` // _id of user who generated this data entry and owns plant responsibility
	PublicPlantID  string             `bson:"public_plant_id" json:"public_plant_id" validate:"required" unique:"true"`
	MountingSystem string             `bson:"mounting_system,omitempty" json:"mounting_system" validate:"max=1000,omitempty" required:"false" unique:"false"` // fixed-tilt systems, single-axis trackers, and dual-axis trackers
	Name           string             `bson:"name" json:"name" validate:"max=200,required" unique:"true"`                                                     // Name of the plant
	Warranty       string             `bson:"warranty" json:"warranty" validate:"max=10000" unique:"false"`                                                   // Informational. The warranties provided by the manufacturers and the expected lifespan of the PV panels and other system components
	NetMeetering   string             `bson:"net_meetering" json:"net_meetering" validate:"max=2000" unique:"false"`                                          // Informational. The ability to feed excess electricity generated by the PV system back into the grid and receive credits or compensation for it.
	Address        string             `bson:"address" json:"address" validate:"max=400" unique:"false"`                                                       // Address (location) where plant is situated
	Coordinates    Coordinates        `bson:"coordinates" json:"coordinates" unique:"false"`                                                                  // Coordinates of the plant
	GridConnection string             `bson:"grid_connection" json:"grid_connection" validate:"max=100" unique:"false"`                                       // grid-tied, off-grid, or hybrid configurations
	NominalPower   int                `bson:"nominal_power" json:"nominal_power" unique:"false"`                                                              // Nominal power in kWp
	ModuleArea     int                `bson:"module_area" json:"module_area" unique:"false"`                                                                  // Area of modules
	ModulesNumber  int                `bson:"modules_number" json:"modules_number" unique:"false"`                                                            // Number of modules
	CreatedAt      time.Time          `bson:"created_at" json:"created_at" validate:"required"`
}

More parameters can be added as per needs In some cases it can make sense to break up the structure into more models/collections

type PlantLogger

type PlantLogger struct {
	ID                 primitive.ObjectID `bson:"_id"`
	VoltageOutput      float64            `bson:"voltage_output" json:"voltage_output" validate:"required"`   // Unit: Volt (V), Symbol: Vdc
	CurrentOutput      float64            `bson:"current_output" json:"current_output" validate:"required"`   // Unit: Ampere (A), Symbol: Idc
	PowerOutput        float64            `bson:"power_output" json:"power_output" validate:"required"`       // Unit: Wattage (W), Symbol: Pdc
	SolarRadiation     float64            `bson:"solar_radiation" json:"solar_radiation" validate:"required"` // Unit: W/m2, Symbol: G
	AmbientTemperature float64            `bson:"t_ambient" json:"t_ambient" validate:"required"`             // Unit: °C, Symbol: Tamb
	ModuleTemperature  float64            `bson:"t_module" json:"t_module" validate:"required"`               // Unit: °C, Symbol: Tmod
	RelativeHumidity   float64            `bson:"rel_humidity" json:"rel_humidity" validate:"required"`       // Rel. humidity a measurement range of 0 to 100% RH
	WindSpeed          float64            `bson:"wind_speed" json:"wind_speed" validate:"required"`           // Unit: m/s, Symbol: Sw
	CreatedAt          time.Time          `bson:"created_at" json:"created_at" validate:"required"`
}

Simplified place holder model More parameters can be added as per needs In some cases it can make sense to break up the structure into more models/collections

type PlantLoggerConfig

type PlantLoggerConfig struct {
	ID                   primitive.ObjectID `bson:"_id"` // Same _id as in PhotovoltaicPlant
	PublicPlantID        string             `bson:"public_plant_id" json:"public_plant_id" validate:"required" unique:"true"`
	IntervalSec          int                `bson:"interval_sec" json:"interval_sec"  validate:"required" unique:"false"` // Important security feature prventing spamming ('rate limiting'). Time window for logging new data (document)
	Key                  string             `bson:"key" json:"key"`
	Secret               string             `bson:"secret" json:"secret"`
	URLID                string             `bson:"url_id" json:"url_id"`
	CollectionNameLogger string             `bson:"collection_name_logger" json:"collection_name_logger" validate:"required" unique:"true"` // Logging of plant measurements is realized with a separate database collection for each plant
	IPWhitelist          []string           `bson:"ip_whitelist" json:"ip_whitelist" unique:"false"`
	CreatedAt            time.Time          `bson:"created_at" json:"created_at" validate:"required"`
}

Configuration of the logging requirements for the API logger More parameters can be added as needed

type UserAuth

type UserAuth struct {
	ID              primitive.ObjectID `bson:"_id,omitempty"`
	Email           string             `bson:"email" json:"email" validate:"required,email,max=255" unique:"true"`
	Password        string             `bson:"password" json:"password,omitempty"`
	Verified        bool               `bson:"verified" json:"verified" default:"false"`
	VerifyToken     string             `bson:"verify_token" json:"verify_token"`
	Blocked         bool               `bson:"blocked" json:"blocked" default:"false"`
	DateVerifyToken time.Time          `bson:"date_verify_token" json:"date_verify_token"`
	CreatedAt       time.Time          `bson:"created_at" json:"created_at" validate:"required"`
}

Jump to

Keyboard shortcuts

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