| OmronConnectedCipNetReadStructT 方法 (String) | 
 [商业授权] 读取一个结构体的对象,需要事先根据实际的数据点位定义好结构体,然后使用本方法进行读取,当结构体定义不对时,本方法将会读取失败
[Authorization] To read a structure object, you need to define the structure in advance according to the actual data points, 
            and then use this method to read. When the structure definition is incorrect, this method will fail to read
            
 
        命名空间: 
     HslCommunication.Profinet.Omron
        程序集:
     HslCommunication (在 HslCommunication.dll 中) 版本:12.5.1.0 (12.5.1.0)
 语法
语法public OperateResult<T> ReadStruct<T>(
	string address
)
where T : struct, new()
Public Function ReadStruct(Of T As {Structure, New}) ( 
	address As String
) As OperateResult(Of T)public:
generic<typename T>
where T : value class, gcnew()
OperateResult<T>^ ReadStruct(
	String^ address
)
member ReadStruct : 
        address : string -> OperateResult<'T>  when 'T : struct, new()
参数
- address
- 类型:SystemString
 结构体对象的地址
类型参数
- T
- 结构体的类型
返回值
类型:
OperateResultT是否读取成功的对象
 备注
备注
            本方法需要商业授权支持,具体的使用方法,参考API文档的示例代码
            
 示例
示例
            我们来看看结构体的操作,假设我们有个结构体
            MyData.Code     STRING(12)
            MyData.Value1   INT
            MyData.Value2   INT
            MyData.Value3   REAL
            MyData.Value4   INT
            MyData.Value5   INT
            MyData.Value6   INT[0..3]
            因为bool比较复杂,暂时不考虑。要读取上述的结构体,我们需要定义结构一样的数据
            
[StructLayout( LayoutKind.Sequential )]
struct MyStruct
{
    [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 12 )]
    public string code;
    public short value1;
    public short value2;
    public float value3;
    public short value4;
    public short value5;
    [MarshalAs( UnmanagedType.ByValArray, SizeConst = 4 )]
    public short[] value6;
}
            定义好后,我们再来读取就很简单了。
            
OperateResult<MyStruct> read = omron.ReadStruct<MyStruct>( "MyData" );
 参见
参见