主要内容

Lamp

显示反映信号灯上信号值的颜色

  • Lamp block

库:
Simulink / Dashboard

描述

Lamp 模块会显示一种颜色,用来指示其所连接的信号的值。要配置 Lamp 模块以提供仿真期间所需的信息,请指定一个或多个状态,这些状态将信号值与要显示的 Lamp 模块的颜色配对。您可以将 Lamp 模块与其他 Dashboard 模块结合使用,为您的模型构建包含各种控件和指示器的交互式仪表板。

信号灯图标

您可以通过选择一个内置图标或上传您自己的自定义图标来更改 Lamp 模块的外观。内置图标包括基本形状、汽车指示灯和无线图标。您可以使用图标参数或使用工具条中的模块选项卡来更改 Lamp 模块的图标。Dashboard 库还包含为每个图标提供预配置的 Lamp 模块版本的库。有关完整的详细信息,请参阅图标

Lamp Icon drop-down menu showing basic shape icons, automotive indicator lamps, wireless icons, and the option to choose a custom icon

如果您要自定义 Lamp 模块的外观(该外观无法通过选择图标来实现),请考虑使用 Customizable Blocks 库中的 Lamp 模块来设计您自己的指示灯。

连接 Dashboard 模块

Dashboard 模块不使用端口来连接到模型元素。要连接 Dashboard 模块,请使用连接模式。要在未连接的模块上进入连接模式,请将鼠标在要连接的模块上暂停并点击连接按钮 。要在已连接的模块上进入连接模式,请选择该模块,在显示的省略号 (…) 上暂停,然后在展开的操作菜单中点击连接按钮。

要将显示模块连接到模型中的信号或更改显示模块的连接,请进入连接模式。选择要连接的信号线。从出现的列表中,选择您要连接的信号。然后,请在 Dashboard 模块上悬停并点击完成连接按钮 。要查看 Dashboard 模块显示连接模块的值,请运行仿真。

有关连接 Dashboard 模块的详细信息,请参阅Connect Dashboard Blocks to Simulink Model

您还可以将 Dashboard 模块连接到 Stateflow® 图。有关详细信息,请参阅Connect Dashboard Blocks to Stateflow (Stateflow)

此动画说明如何将 Lamp 模块连接到您的模型。

An unconnected Lamp block connects to the signal that a Ramp block sends to a Terminator block.

示例

全部展开

您可以使用 Lamp 模块来指示所连接信号的值。例如,模型 lampStep 包含一个 Step 模块,该模块在时间 3 处将值从 0 更改为 1。Step 模块的输出信号 StepSig 连接到 Lamp 模块。

The Block Parameter dialog box for the Lamp block

对模型进行仿真。当 StepSig 的值为 0 时,信号灯为绿色。当 StepSig 的值为 1 时,信号灯为蓝色。

Animation of the lampStep model during simulation

扩展示例

限制

  • 除了 Dashboard Scope 模块和 Display 模块之外,Dashboard 模块只能连接到实数标量信号。

  • 您不能在“模块参数”对话框中使用连接表将 Dashboard 模块连接到已注释掉的模块。使用连接模式将 Dashboard 模块连接到带注释的模块时,Dashboard 模块在您取消注释模块之前不会显示连接的值。

  • Dashboard 模块无法连接到引用模型中的模型元素。

  • 在仿真模型层次结构时,引用模型内的 Dashboard 模块不会更新。

  • Dashboard 模块不支持快速加速仿真。

  • 在仿真期间,您无法将 Dashboard 模块连接到 Stateflow 图数据或状态活动。

  • 您无法以编程方式将 Dashboard 模块连接到 Stateflow 图数据或状态活动。

  • 由于加速模式仿真的模块简化或优化,一些信号在仿真期间没有可用的数据。要使用 Dashboard 模块查看此类信号,请标记信号以进行记录。

参数

全部展开

此模块是显示模块 - 显示信号值的模块。将该模块连接到您要显示的信号。

Dashboard 模块不使用端口来连接到模型元素。要连接 Dashboard 模块,请使用连接模式、Simulink® 工具条或“模块参数”对话框中的连接表。有关信息,请参阅Connect Dashboard Blocks to Simulink Model

要使用连接表连接到信号,请执行以下操作:

  1. 选择模块。

  2. 在属性检查器中,在参数选项卡上,点击连接更改

  3. 选择您要连接到其信号的信号线。

  4. 在出现的表中,选择该信号。

  5. 点击应用

您还可以将 Dashboard 模块连接到 Stateflow 图。有关详细信息,请参阅Connect Dashboard Blocks to Stateflow (Stateflow)

编程用法

您可以通过编程方式将显示模块连接到信号。定义表示该信号的 Simulink.HMI.SignalSpecification 对象。然后,将 Binding 参数的值设置为该对象。要设置 Binding 参数的值,请使用 set_param 函数。

例如,假设名为 vdp 的模型包含名为 myGaugeCircular Gauge 模块和名为 x1 的信号。要将此模块连接到信号,请使用以下代码。

blockPath = "vdp/myGauge";
signalPath = "vdp/x1";

myObj = Simulink.HMI.SignalSpecification;
myObj.BlockPath = Simulink.BlockPath(signalPath);

set_param(blockPath,Binding=myObj)
参数: Binding
值: Simulink.HMI.SignalSpecification object

示例: set_param(gcb,Binding=myObj)

每个状态都将一个与一种颜色配对。

  • - 所连接信号的值

  • 颜色 - 当所连接信号具有该值时 Lamp 模块显示的颜色

要添加状态,请点击 + 按钮。要删除状态,请在状态表中,选择该状态对应的行,然后点击 X 按钮。

要编辑状态值,请在列中,点击该值,删除该值,然后输入新值。要编辑颜色,请在颜色列中,点击该颜色,然后选择一种新颜色。您可以从标准颜色调色板中选择,也可以使用 RGB 值指定自定义颜色。

[undefined] 状态指定当连接的信号值与状态表中指定的任何值都不匹配时,Lamp 模块的颜色。

编程用法

要以编程方式设置模块参数值,请使用 set_param 函数。

StateColors 参数的值指定为一个结构体数组,其中每个结构体表示一种状态。每个结构体包含以下字段:

  • Value - 信号值

  • Color - 当所连接信号具有该值时 Lamp 模块显示的颜色

例如,假设您需要当前选定的 Lamp 模块具有两个状态。在第一个状态中,当所连接信号的值为 0 时,模块显示蓝色。在第二个状态中,当所连接信号的值为 2 时,模块显示红色。要实现这些状态,请使用以下代码。

state1.Value = 1;
state1.Color = [0 0 1];
state2.Value = 2;
state2.Color = [1 0 0];
myStates = [state1 state2];

set_param(gcb,StateColors=myStates)
参数: StateColors
值: N-by-1 struct array, where N is the number of states and each struct has the fields Value and Color

示例: set_param(gcb,StateColors=myStates)

ColorDefault 参数指定当所连接信号的值与任何指定的状态值都不匹配时,Lamp 模块的颜色。

参数: ColorDefault
值: [0.7529 0.7529 0.7529] (默认) | [r g b] vector with values between 0 and 1

示例: set_param(gcb,ColorDefault=[1 0 1])

使用一个图标来配置模型中 Lamp 模块的外观。您可以从内置形状、汽车图标和无线图标中进行选择,也可以上传您自己的自定义 SVG 文件作为图标。

要查看图标选项,请在图标选项卡上选择图标类型。要使用您自己的 SVG 文件作为模块图标,请选择自定义作为图标类型并上传 SVG 文件。Lamp 模块的状态颜色可以应用于下列 SVG 元素:

  • altGlyph

  • circle

  • ellipse

  • path

  • polygon

  • rect

  • text

  • textPath

  • tref

  • tspan

形状图标

图标基本形状库模块名称编程使用的值

Lamp icon: a solid gray circle

LampDefault

Circle icon: a solid black circle

CircleCircle

Hexagon icon: a solid hexagon

HexagonHexagon

Pentagon icon: a solid pentagon

PentagonPentagon

Rectangle icon: a solid rectangle

RectangleRectangle

Square icon: a solid square

SquareSquare

Triangle icon: a solid triangle

TriangleTriangle

Check1 icon: a check mark

Check1Check1

Check2 icon: a check mark with slightly curved lines

Check2Check2

Check3 icon: the outline of a check mark

Check3Check3

Check4 icon: a check mark with a divot along its outline

Check4Check4

Ex1 icon: a cross mark

Ex1Ex1

Ex2 icon: a cross mark with one curved line

Ex2Ex2

Ex3 icon: the outline of a cross mark

Ex3Ex3

Ex4 icon: a cross mark with a divot along the outline

Ex4Ex4

Face icon: the outline of a face with a closed mouth in a straight line

FaceFace

Frown1 icon: the outline of a face with an open downturned mouth

Frown1Frown1

Frown2 icon: the outline of a face with a closed downturned mouth

Frown2Frown2

Smile1 icon: the outline of a face with an open upturned mouth

Smile1Smile1

Smile2 icon: the outline of a face with a closed upturned mouth

Smile2Smile2

Solid Face icon: a solid face with a closed mouth in a straight line

Solid FaceSolidFace

Solid Frown1 icon: a solid face with an open downturned mouth

Solid Frown1SolidFrown1

Solid Frown2 icon: a closed downturned mouth

Solid Frown2SolidFrown2

Solid Smile1 icon: a solid face with an open upturned mouth

Solid Smile1SolidSmile1

Solid Smile2 icon: a solid face with a closed upturned mouth

Solid Smile2SolidSmile2

汽车图标

图标汽车指示灯库模块名称编程使用的值

Adaptive Cruise Control icon: a speedometer with an arrow pointing to a tick mark and the silhouette of a car in the background

Adaptive Cruise ControlAdaptiveCruiseControl

Adaptive Cruise Control Failure icon: a speedometer with an exclamation mark next to it and the silhouette of a car in the background

Adaptive Cruise Control FailureAdaptiveCruiseControlFailure

Anti-Lock Brake System icon: a circle labeled "ABS" in a set of parentheses

Antilock Brake SystemAntilockBrakeSystem

Battery icon: the outline of a battery with a plus symbol on the positive pole, and a negative symbol on the negative pole

BatteryBattery

Check Engine icon: the outline of an engine labeled "Check Engine"

Check EngineCheckEngine

Check Engine2 icon: the outline of an engine with the silhouette of a lightning rod on it and the word "CHECK" underneath it

Check Engine2CheckEngine2

Cruise Control icon: a speedometer with an arrow pointing to one of the tick marks

Cruise ControlCruiseControl

Eco Mode icon: a solid leaf shape labeled "ECO"

Eco ModeEcoMode

Electronic Stability icon: a circle labeled "ESP" in a set of parentheses

Electronic StabilityElectronicStability

Engine icon: the silhouette of an engine

EngineEngine

Engine Coolant Temp icon: a thermometer with waves in the background

Engine Coolant TempEngineCoolantTemp

Engine Failure icon: the silhouette of an engine with an exclamation mark on it

Engine FailureEngineFailure

Engine Heating icon: the silhouette of an engine with three wavy arrows pointing upwards on it

Engine HeatingEngineHeating

Engine Oil icon: the silhouette of an oil can

Engine OilEngineOil

Exterior Bulb Failure icon: the silhouette of a glowing light bulb with an exclamation mark on it

Exterior Bulb FailureExteriorBulbFailure

Front Fog Light icon: the outline of a fog light lamp emitting rays of light to the left that are depicted as diagonal lines on top of a wavy vertical line that represents the fog

Front Fog LightFrontFogLight

Fuel icon: the silhouette of a gas pump with an arrow pointing left on it

FuelFuel

Hazards icon: the outline of a warning triangle

HazardsHazards

Headlamp Leveling icon: the outline of a lamp emitting rays of light with an arrow pointing clockwise above them and an arrow pointing counterclockwise below them

Headlamp LevelingHeadlampLeveling

High Beams icon: the outline of a lamp emitting horizontal rays of light

High BeamsHighBeams

Hill Descent Control icon: the outline of a car driving down a slope

Hill Descent ControlHillDescentControl

Lighting Switch icon: the silhouette of a glowing light bulb

Lighting SwitchLightingSwitch

High Beams icon: the outline of a lamp emitting rays of light that run diagonally downward

Low BeamsLowBeams

Parking Assistance icon: the letter "P" next to a solid triangle, and the "P" emits a detection signal represented as three curved lines aimed at the triangle

Parking AssistanceParkingAssistance

Rear Fog Light icon: the outline of a fog light lamp emitting rays of light to the right that are depicted as horizontal lines on top of a wavy vertical line that represents the fog

Rear Fog LightRearFogLight

Side Lights icon: the outline two lamps emitting rays of light to the left and right

Side LightsSideLights

Stability Control icon: the silhouette of a car with wavy lines behind it

Stability ControlStabilityControl

Stability Control Off icon: the silhouette of a car with wavy lines behind it and the word "OFF" underneath

Stability Control OffStabilityControlOff

Tire Monitor icon: the outline of the cross-section of a tire with an exclamation mark on it

Tire MonitorTireMonitor

Traction Control icon: the outline of the cross-section of a tire with the label "TC"

Traction ControlTractionControl

Traction Control Off icon: the outline of the cross-section of a tire with the label "TC" and a diagonal slash through the whole image

Traction Control OffTractionControlOff

Traction Control Failure icon: the outline of the cross-section of a tire with the label "TC" and an exclamation mark next to it

Traction Control FailureTractionControlFailure

Turn Signal Left icon: a solid arrow pointing left

Turn Signal LeftTurnSignalLeft

Turn Signal Right icon: a solid arrow pointing right

Turn Signal RightTurnSignalRight

无线图标

图标图标名称编程使用的值

Network icon: the wireless internet connection icon

NetworkNetwork

Network No Signal icon: the wireless internet connection icon grayed out,with a crossed-out circle next to it

Network No SignalNetworkNoSignal

Network Transmission icon: a wireless internet tower

Network TransmissionNetworkTransmission

Network3G icon: the wireless internet connection icon with "3G" next to it

Network3GNetwork3G

Network4G icon: the wireless internet connection icon with "4G" next to it

Network4GNetwork4G

Network5G icon: the wireless internet connection icon with "4G" next to it

Network5GNetwork5G

提示

  • 您可以使用工具条中的模块选项卡更改 Lamp 模块的图标。

  • Dashboard 库包含为每个图标提供预配置 Lamp 模块的库。

  • 如果您要自定义 Lamp 模块的外观(该外观无法通过选择图标来实现),请考虑使用 Customizable Blocks 库中的 Lamp 模块来设计您自己的指示灯。

编程用法

要以编程方式设置模块参数值,请使用 set_param 函数。

参数: Icon
值: 'Default' (默认) | icon name formatted as string or character vector

示例: set_param(gcb,Icon="NetworkTransmission")

模块标签的位置。当模块连接到模型中的元素时,标签是所连接的元素的名称。

编程用法

要以编程方式设置模块参数值,请使用 set_param 函数。

参数: LabelPosition
值: 'Top' (默认) | "Top" | "Bottom" | "Hide"

示例: set_param(gcb,LabelPosition="Bottom")

模块不透明度,指定为 0 到 1 之间的标量值。

编程用法

要以编程方式设置模块参数值,请使用 set_param 函数。

参数: Opacity
值: '1' (默认) | scalar with values between 0 and 1 formatted as string or character vector

示例: set_param(gcb,Opacity="0.5")

模块特性

数据类型

Boolean | double | enumerated | fixed point | half | integer | single

直接馈通

多维信号

可变大小信号

过零检测

扩展功能

全部展开

版本历史记录

在 R2015a 中推出

全部展开