Documentation
¶
Overview ¶
Package nimsforestviewer provides a unified visualization viewer for Smart TVs and web browsers.
Index ¶
- func ViewStateToJSONBytes(state *ViewState) ([]byte, error)
- type CallbackStateProvider
- type LandJSON
- type LandView
- type Option
- type ProcessJSON
- type ProcessView
- type SmartTVTarget
- type SpritesStateAdapter
- type StateProvider
- type StaticStateProvider
- type SummaryJSON
- type SummaryView
- type TVOption
- type Target
- type VideoOption
- type VideoTarget
- func (t *VideoTarget) Close() error
- func (t *VideoTarget) Name() string
- func (t *VideoTarget) SetStateProvider(p StateProvider)
- func (t *VideoTarget) Start(ctx context.Context) error
- func (t *VideoTarget) Stop(ctx context.Context) error
- func (t *VideoTarget) Update(ctx context.Context, state *ViewState) error
- type ViewState
- type Viewer
- type WebOption
- type WebTarget
- type WorldJSON
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ViewStateToJSONBytes ¶
ViewStateToJSONBytes converts a ViewState to JSON bytes.
Types ¶
type CallbackStateProvider ¶
type CallbackStateProvider struct {
// contains filtered or unexported fields
}
CallbackStateProvider calls a function to get state.
func NewCallbackStateProvider ¶
func NewCallbackStateProvider(fn func() (*ViewState, error)) *CallbackStateProvider
NewCallbackStateProvider creates a StateProvider from a callback function.
func (*CallbackStateProvider) GetViewState ¶
func (p *CallbackStateProvider) GetViewState() (*ViewState, error)
GetViewState implements StateProvider.
type LandJSON ¶
type LandJSON struct {
ID string `json:"id"`
Hostname string `json:"hostname"`
RAMTotal uint64 `json:"ram_total"`
RAMAllocated uint64 `json:"ram_allocated"`
CPUCores int `json:"cpu_cores,omitempty"`
CPUFreqGHz float64 `json:"cpu_freq_ghz,omitempty"`
GPUVram uint64 `json:"gpu_vram,omitempty"`
GPUTflops float64 `json:"gpu_tflops,omitempty"`
Occupancy float64 `json:"occupancy"`
IsManaland bool `json:"is_manaland"`
GridX int `json:"grid_x"`
GridY int `json:"grid_y"`
Trees []ProcessJSON `json:"trees"`
Treehouses []ProcessJSON `json:"treehouses"`
Nims []ProcessJSON `json:"nims"`
}
LandJSON is the JSON representation of a Land tile.
type LandView ¶
type LandView struct {
ID string
Hostname string
GridX, GridY int
IsManaland bool
Occupancy float64
RAMTotal uint64
RAMAllocated uint64
Trees []ProcessView
Treehouses []ProcessView
Nims []ProcessView
}
LandView represents a single land/node in the visualization.
func (*LandView) AllProcesses ¶
func (l *LandView) AllProcesses() []ProcessView
AllProcesses returns all processes on this land.
type Option ¶
type Option func(*Viewer)
Option configures the Viewer.
func WithInterval ¶
WithInterval sets the update interval for periodic updates.
type ProcessJSON ¶
type ProcessJSON struct {
ID string `json:"id"`
Name string `json:"name"`
RAMAllocated uint64 `json:"ram_allocated"`
Type string `json:"type"`
Progress float64 `json:"progress,omitempty"`
Subjects []string `json:"subjects,omitempty"`
ScriptPath string `json:"script_path,omitempty"`
AIEnabled bool `json:"ai_enabled,omitempty"`
Model string `json:"model,omitempty"`
}
ProcessJSON is the JSON representation of a process.
type ProcessView ¶
type ProcessView struct {
ID string
Name string
Type string // "tree", "treehouse", "nim"
RAMAllocated uint64
Progress float64
}
ProcessView represents a process running on a land.
type SmartTVTarget ¶
type SmartTVTarget struct {
// contains filtered or unexported fields
}
SmartTVTarget displays static images on Smart TVs via DLNA. Uses nimsforestsprites for passive rendering and nimsforestsmarttv for transport.
func NewSmartTVTarget ¶
func NewSmartTVTarget(tv *smarttv.TV, opts ...TVOption) (*SmartTVTarget, error)
NewSmartTVTarget creates a target that displays images on a Smart TV.
type SpritesStateAdapter ¶
type SpritesStateAdapter struct {
// contains filtered or unexported fields
}
SpritesStateAdapter adapts ViewState to sprites.State interface.
func NewSpritesStateAdapter ¶
func NewSpritesStateAdapter(state *ViewState) *SpritesStateAdapter
NewSpritesStateAdapter creates an adapter for sprites rendering.
func (*SpritesStateAdapter) Lands ¶
func (a *SpritesStateAdapter) Lands() []sprites.Land
Lands implements sprites.State.
func (*SpritesStateAdapter) Processes ¶
func (a *SpritesStateAdapter) Processes() []sprites.Process
Processes implements sprites.State.
type StateProvider ¶
type StateProvider interface {
// GetViewState returns the current visualization state.
GetViewState() (*ViewState, error)
}
StateProvider provides the current ViewState for visualization.
type StaticStateProvider ¶
type StaticStateProvider struct {
// contains filtered or unexported fields
}
StaticStateProvider wraps a fixed ViewState.
func NewStaticStateProvider ¶
func NewStaticStateProvider(state *ViewState) *StaticStateProvider
NewStaticStateProvider creates a StateProvider from a fixed ViewState.
func (*StaticStateProvider) GetViewState ¶
func (p *StaticStateProvider) GetViewState() (*ViewState, error)
GetViewState implements StateProvider.
type SummaryJSON ¶
type SummaryJSON struct {
LandCount int `json:"land_count"`
ManalandCount int `json:"manaland_count"`
TreeCount int `json:"tree_count"`
TreehouseCount int `json:"treehouse_count"`
NimCount int `json:"nim_count"`
TotalRAM uint64 `json:"total_ram"`
RAMAllocated uint64 `json:"ram_allocated"`
Occupancy float64 `json:"occupancy"`
}
SummaryJSON is the JSON representation of the world summary.
type SummaryView ¶
type SummaryView struct {
TotalLands int
TotalManalands int
TotalTrees int
TotalTreehouses int
TotalNims int
TotalRAM uint64
AllocatedRAM uint64
}
SummaryView contains aggregate statistics.
type TVOption ¶
type TVOption func(*SmartTVTarget)
TVOption configures a SmartTVTarget.
func WithJFIF ¶
WithJFIF enables JFIF conversion for better TV compatibility. Requires ffmpeg and imagemagick to be installed.
func WithSpriteOptions ¶
WithSpriteOptions sets the sprite renderer options.
type Target ¶
type Target interface {
// Update sends new state to the target.
Update(ctx context.Context, state *ViewState) error
// Close cleans up the target.
Close() error
// Name returns a descriptive name for logging.
Name() string
}
Target represents a visualization output destination.
type VideoOption ¶
type VideoOption func(*VideoTarget)
VideoOption configures a VideoTarget.
func WithVideoDuration ¶
func WithVideoDuration(d time.Duration) VideoOption
WithVideoDuration sets the video duration.
func WithVideoSpriteOptions ¶
func WithVideoSpriteOptions(opts sprites.Options) VideoOption
WithVideoSpriteOptions sets the sprite renderer options for video.
type VideoTarget ¶
type VideoTarget struct {
// contains filtered or unexported fields
}
VideoTarget streams continuous video to Smart TVs. Uses nimsforestsprites for rendering and ffmpeg for encoding.
func NewVideoTarget ¶
func NewVideoTarget(tv *smarttv.TV, opts ...VideoOption) (*VideoTarget, error)
NewVideoTarget creates a target that streams video to a Smart TV.
func (*VideoTarget) SetStateProvider ¶
func (t *VideoTarget) SetStateProvider(p StateProvider)
SetStateProvider sets the state provider for continuous frame generation.
func (*VideoTarget) Start ¶
func (t *VideoTarget) Start(ctx context.Context) error
Start begins video streaming to the TV. This pre-renders a video file and streams it.
type ViewState ¶
type ViewState struct {
Lands []LandView
Summary SummaryView
}
ViewState represents the complete visualization state.
type Viewer ¶
type Viewer struct {
// contains filtered or unexported fields
}
Viewer manages visualization output to multiple targets.
func (*Viewer) RemoveTarget ¶
RemoveTarget removes a target by reference.
func (*Viewer) SetStateProvider ¶
func (v *Viewer) SetStateProvider(p StateProvider)
SetStateProvider sets the source of ViewState.
type WebOption ¶
type WebOption func(*WebTarget)
WebOption configures a WebTarget.
func WithWebDir ¶
WithWebDir sets the directory containing static web assets.
type WebTarget ¶
type WebTarget struct {
// contains filtered or unexported fields
}
WebTarget serves the visualization via HTTP for web browsers. It provides a JSON API at /api/viewmodel and can serve static assets.
func NewWebTarget ¶
NewWebTarget creates a target that serves the visualization via HTTP.
type WorldJSON ¶
type WorldJSON struct {
Lands []LandJSON `json:"lands"`
Summary SummaryJSON `json:"summary"`
}
WorldJSON is the JSON representation of ViewState for the web frontend.
func ViewStateToJSON ¶
ViewStateToJSON converts a ViewState to WorldJSON for the web frontend.