Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

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

使用连接表连接 Display 模块或更改 Display 模块的连接:

  1. 选择模块。

  2. 要连接该模块,请在属性检查器的参数选项卡上点击连接。要更改模块的连接,请改为点击更改

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

  4. 在表中,选择要连接的信号。

  5. 点击应用

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

编程用法

模块参数Binding
类型:Simulink.HMI.SignalSpecification
默认值:[]

状态将显示颜色与连接的信号值的相匹配。每个状态由状态颜色组成。

  • 状态 - 使 Lamp 模块显示指定颜色的已连接信号值。

  • 颜色 - 当连接的信号值与对应的状态值匹配时信号灯的颜色。您可以从标准颜色调色板中选择,也可以使用 RGB 值指定自定义颜色。

[undefined] 状态指定当连接的信号值与状态表中指定的任何值都不匹配时,Lamp 模块的颜色。点击 + 按钮可添加另一个状态。

编程用法

要以编程方式为 Lamp 模块指定 StateColor 参数值,请使用包含以下字段的结构体数组:

  • Value - 导致 Lamp 模块显示指定颜色指示的标量 double 信号值。

  • Color - 1×3 [r g b] 向量,其值介于 01 之间,指定要显示的 Lamp 模块的颜色。

lampState1.Value = 1;
lampState1.Color = [0 0 1];
lampState2.Value = 2;
lampState2.Color = [1 0 0];
lampStates = [lampState1 lampState2];
模块参数StateColors
类型:结构体数组
默认值:结构体

ColorDefault 参数指定当所连接信号的值与任何指定的状态值都不匹配时,Lamp 模块的颜色。将 ColorDefault 参数指定为 1×3 [r g b] 向量,其值介于 01 之间。

模块参数ColorDefault
类型:[r g b] 向量
默认值[0.7529 0.7529 0.7529]

使用一个图标来配置模型中 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 模块来设计您自己的指示灯。

编程用法

模块参数Icon
类型:字符串 | 字符向量
默认值:'Default'

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

编程用法

模块参数LabelPosition
类型:字符向量
'Top' | 'Bottom' | 'Hide'
默认值'Top'

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

示例: 0.5

编程用法

模块参数:Opacity
类型:标量
默认值: 1

模块特性

数据类型

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

直接馈通

多维信号

可变大小信号

过零检测

扩展功能

版本历史记录

在 R2015a 中推出