Simulink.bus的定义
BusDemo = Simulink.Bus;
BusDemo.Description = '';
BusDemo.DataScope = 'Exported';
BusDemo.HeaderFile = '';
BusDemo.Alignment = -1;
busElement1 = Simulink.BusElement;
busElement1.name = 'busElement1';
busElement1.Complexity = 'real';
busElement1.Dimensions = 1;
busElement1.DataType = 'uint32';
busElement1.Min = [];
busElement1.Max = [];
busElement1.DimensionsMode = 'Fixed';
busElement1.SamplingMode = 'Sample based';
busElement1.SampleTime = -1;
busElement1.DocUnits = '';
busElement1.Description = '';
busElement2 = Simulink.BusElement;
busElement2.name = 'busElement2';
busElement2.Complexity = 'real';
busElement2.Dimensions = 240;
busElement2.DataType = 'uint8';
busElement2.Min = [];
busElement2.Max = [];
busElement2.DimensionsMode = 'Fixed';
busElement2.SamplingMode = 'Sample based';
busElement2.SampleTime = -1;
busElement2.DocUnits = '';
busElement2.Description = '';
BusDemo.Elements = [busElement1 busElement2];
assignin( 'base', 'busDemo', BusDemo);
在s-function(c语言)中,注册simulink.bus 并设置端口类型。
nameBusStr = “busDemo”;
DTypeId dataTypeIdReg;
ssRegisterTypeFromNamedObject(
S,
nameBusStr,
&dataTypeIdReg);
if (dataTypeIdReg == INVALID_DTYPE_ID)
return;
/*mexPrintf("nameBusStr: %s\n",nameBusStr);*/
ssSetOutputPortDataType(S, 1, dataTypeIdReg );
ssSetBusObjectName(S, 1, (void *)nameBusStr);
ssSetBusOutputAsStruct(S, 1, 1);
联系客服