machinedowntimeep

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MachineDowntimeEventFromProto

func MachineDowntimeEventFromProto(info *pb.MachineDowntimeEventInfo) apiresource.MachineDowntimeEvent

MachineDowntimeEventFromProto maps a core MachineDowntimeEventInfo to the API resource. The machine, department, item and reported_by expandables are left nil; pair with StashMachineDowntimeEventMeta so they resolve on ?include=.

func MachineDowntimeReasonFromProto

func MachineDowntimeReasonFromProto(info *pb.MachineDowntimeReasonInfo) apiresource.MachineDowntimeReason

MachineDowntimeReasonFromProto maps a core MachineDowntimeReasonInfo to the API resource.

func StashMachineDowntimeEventMeta

func StashMachineDowntimeEventMeta(ctx context.Context, meta *resourcekit.LoadMeta, info *pb.MachineDowntimeEventInfo) *apiresource.Actor

StashMachineDowntimeEventMeta stashes the FK ids in LoadMeta so the loaders can resolve the expandable machine, department, item and reported_by on ?include=. The reporter is stored as a bare identity-actor id, so its Actor is built from the id's prefix and preheated — LoadActors has no backing store. The built actor is returned (nil when absent) so the caller can batch-hydrate display names.

Types

type CreateMachineDowntimeEventEndpoint

type CreateMachineDowntimeEventEndpoint struct{}

Logs a machine downtime event.

Give the stoppage an end either as `ended_at` or as a `duration` counted in a unit of time — sending both is rejected. Omit `ended_at` while the machine is still down. A machine can only have one open event at a time, so logging a second open stoppage against a machine that is already down is rejected until the first is closed.

The department is taken from the machine, the business day is taken from `started_at`, the event is attributed to the credentials that made the request, and the duration is calculated when the event is closed.

type CreateMachineDowntimeEventRequest

type CreateMachineDowntimeEventRequest struct {
	// ID of the machine that stopped.
	MachineID string `json:"machine_id" validate:"required"`
	// Why the machine stopped.
	//
	// The reason decides which OEE term the stoppage charges, so it does more than label the event. Retrieve the available reasons and the term each one charges from the downtime reasons list.
	Reason constants.MachineDowntimeReasonCode `json:"reason" validate:"required"`
	// When the machine stopped.
	//
	// Cannot be in the future beyond a few minutes of clock skew, which is allowed so a shop-floor tablet running fast can still log "just now". The business day the stoppage counts against is taken from this timestamp.
	StartedAt time.Time `json:"started_at" validate:"required"`
	// When the machine started running again.
	//
	// Omit it while the machine is still down; that leaves the event open, and the duration is filled in once the event is closed. It must be later than `started_at`.
	EndedAt field.Optional[time.Time] `json:"ended_at,omitzero"`
	// How long the machine was down, counted in a unit of time.
	//
	// The end time is derived from `started_at` plus this. Send either send `ended_at` or `duration`. The unit must measure time.
	Duration field.Optional[apirequest.QuantityInput] `json:"duration,omitzero"`
	// ID of the item the machine was running when it stopped.
	ItemID field.Optional[string] `json:"item_id,omitzero"`
	// ID of the production run in progress when the machine stopped.
	ProductionRunID field.Optional[string] `json:"production_run_id,omitzero"`
	// ID of the batch in progress when the machine stopped.
	BatchID field.Optional[string] `json:"batch_id,omitzero"`
	// Free-form notes about the stoppage.
	//
	// Searchable from the downtime events list. Maximum 2000 characters.
	Note field.Optional[string] `json:"note,omitzero" validate:"omitempty,max=2000"`
	// How the event was recorded.
	//
	// Records the stoppage as manually logged unless you say otherwise, so an integration or shop-floor station should send its own source to keep hand-entered downtime distinguishable.
	Source field.Optional[constants.MachineDowntimeSource] `json:"source,omitzero"`
}

Request to log a machine downtime event.

func (*CreateMachineDowntimeEventRequest) SchemaExample

func (*CreateMachineDowntimeEventRequest) SchemaExample() any

type DeleteMachineDowntimeEventEndpoint

type DeleteMachineDowntimeEventEndpoint struct{}

Deletes a machine downtime event.

Meant for a stoppage that was logged by mistake: the event is removed permanently and stops counting against the machine's availability. To correct a real stoppage, update it instead so the record of the downtime survives.

type DeleteMachineDowntimeEventRequest

type DeleteMachineDowntimeEventRequest struct {
	// ID of the downtime event to delete.
	MachineDowntimeEventID string `path:"id" validate:"required"`
}

Request to delete a machine downtime event.

type ListMachineDowntimeEventsEndpoint

type ListMachineDowntimeEventsEndpoint struct{}

Returns a paginated list of machine downtime events, most recently started first.

The search term matches text in the event note. Filters combine, so a machine, a reason and a date range narrow the list together.

type ListMachineDowntimeEventsRequest

type ListMachineDowntimeEventsRequest struct {
	apiresource.PaginationRequest
	// Only return events for these machines.
	MachineIDs []string `query:"machine_ids"`
	// Only return events for machines in these departments.
	DepartmentIDs []string `query:"department_ids"`
	// Only return events logged against these reasons.
	Reasons []constants.MachineDowntimeReasonCode `query:"reasons"`
	// Only return events that are still open, meaning the machine is down right now.
	//
	// Sending `false` is the same as leaving it out: both open and closed events come back.
	Open bool `query:"open"`
	// Only return events that started on or after this timestamp, formatted as RFC3339.
	StartDate *string `query:"starts_at"`
	// Only return events that started on or before this timestamp, formatted as RFC3339.
	EndDate *string `query:"ends_at"`
}

Request to list machine downtime events.

type ListMachineDowntimeReasonsEndpoint

type ListMachineDowntimeReasonsEndpoint struct{}

Returns the downtime reasons available when logging a stoppage.

The list is the same for every account and is ordered for display, so it can be rendered straight into a reason picker. Each reason carries the OEE term its stoppages charge, which is what makes the choice of reason matter beyond labeling.

type ListMachineDowntimeReasonsRequest

type ListMachineDowntimeReasonsRequest struct{}

Request to list downtime reasons.

type MachineDowntimeSvcConfig

type MachineDowntimeSvcConfig struct {
	// CoreClient (required) is the core-service machine-downtime gRPC client.
	CoreClient pb.CoreMachineDowntimeServiceClient
}

type RetrieveMachineDowntimeEventEndpoint

type RetrieveMachineDowntimeEventEndpoint struct{}

Returns a single machine downtime event.

type RetrieveMachineDowntimeEventRequest

type RetrieveMachineDowntimeEventRequest struct {
	// ID of the downtime event to retrieve.
	MachineDowntimeEventID string `path:"id" validate:"required"`
}

Request to retrieve a machine downtime event.

type UpdateMachineDowntimeEventEndpoint

type UpdateMachineDowntimeEventEndpoint struct{}

Closes or corrects a machine downtime event.

Only the fields provided in the request are changed. Setting `ended_at` — or a `duration`, which says the same thing as a length of time from the start — closes the event and calculates how long it lasted; sending either as null reopens an event closed by mistake, which is rejected when the machine already has another open stoppage. Moving the event to another machine re-resolves the department the stoppage is charged to.

type UpdateMachineDowntimeEventRequest

type UpdateMachineDowntimeEventRequest struct {
	// ID of the downtime event to update.
	MachineDowntimeEventID string `path:"id" validate:"required"`
	// ID of the machine that stopped.
	//
	// Moving an event to another machine re-resolves the department it is charged to, so past availability changes for both rooms. Rejected when the destination machine already has an open stoppage and this one is open too.
	MachineID field.Optional[string] `json:"machine_id,omitzero"`
	// Why the machine stopped.
	//
	// Reclassifying a stoppage moves it to the OEE term the new reason charges, so past availability figures change with it.
	Reason field.Optional[constants.MachineDowntimeReasonCode] `json:"reason,omitzero"`
	// When the machine stopped.
	//
	// Correcting it recalculates the duration and can move the stoppage onto a different business day.
	StartedAt field.Optional[time.Time] `json:"started_at,omitzero"`
	// When the machine started running again.
	//
	// Setting it closes the event and records the duration. Send null to reopen an event that was closed by mistake, which is rejected if the machine has since had another stoppage logged that is still open.
	EndedAt field.Clearable[time.Time] `json:"ended_at,omitzero"`
	// How long the machine was down, counted in a unit of time.
	//
	// Restates the end as a length of time from the start, so it is applied against `started_at` as this request leaves it. Send this or `ended_at`, never both. Send null to reopen the event.
	Duration field.Clearable[apirequest.QuantityInput] `json:"duration,omitzero"`
	// ID of the item the machine was running when it stopped.
	//
	// Send null to detach the item.
	ItemID field.Clearable[string] `json:"item_id,omitzero"`
	// ID of the production run in progress when the machine stopped.
	//
	// Send null to detach the run.
	ProductionRunID field.Clearable[string] `json:"production_run_id,omitzero"`
	// ID of the batch in progress when the machine stopped.
	//
	// Send null to detach the batch.
	BatchID field.Clearable[string] `json:"batch_id,omitzero"`
	// Free-form notes about the stoppage.
	//
	// Send null to remove the note. Maximum 2000 characters.
	Note field.Clearable[string] `json:"note,omitzero" validate:"omitempty,max=2000"`
}

Request to update a machine downtime event.

func (*UpdateMachineDowntimeEventRequest) SchemaExample

func (*UpdateMachineDowntimeEventRequest) SchemaExample() any

Jump to

Keyboard shortcuts

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