Class Ledgrid.device_led_grid


class device_led_grid : on_xpm_file_name:string -> off_xpm_file_name:string -> nothing_xpm_file_name:string -> ?show_100_mbs:bool -> ports:int -> packing:(GObj.widget -> unit) -> ?angle:float -> ?lines:int -> unit -> object .. end
A 'device LED grid' is a LED grid specialized as a realistic simulation of the control panel of a physical device such as a switch, a hub or a router. A device LED's appearance can be customized at creation time, and this class allows the user to control each _port_, abstracting from the position of the light or lights representing the port state. Port information can be displayed in either one or two lines, and an optional "100Mb/s" array of lights can also be shown. The number of ports must be even when two lines are requested. Three pixmap file names are required at creation time, as for the LED grid. Labels are automatically set. Reflecting the interface of common network devices, it can be said that a port is either in 'connected' or 'disconnected' state, meaning that its associated lights are 'on' or 'off' (and discounting flashes and blinks). Notice that, as in most real-world switch and hubs, port numeration is 1-based.
Inherits
method private port_to_positions : int -> (int * int) list
Given a port number, return a list of pairs of coordinates identifying the inolved lights:
method private port_to_positions_ : int -> (int * int) list
Print the port->coordinates mapping before returning the result of calling port_to_positions:
method private port_to_led_lights : int -> led_light list
Given a port number, return the list of LED lights representing it:
method private for_each_led_light : (led_light -> unit) -> int -> unit list
For each LED light representing the given port, call the given function and return the list of results:
method flash : int -> unit
Ask every LED light representing the given port to (asynchronously) flash:
method blink : int -> unit
Ask every LED light representing the given port to (asynchronously) blink:
method set : int -> bool -> unit
Set the state of all LED lights representing a port, updating their default state: this is a good way to indicate a cable connection or disconnection:
method connect : int -> unit
method disconnect : int -> unit
method random_connected_port : int
Return the number of a random port currently in the 'On' state, or loop forever if no such port exists. This is useful for debugging and demos :-)
method is_connected : int -> bool
Return true iff the given port is in connected state: