外部確保の領域設定 (アタッチ指定)
Namespace: FVILAssembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)
Syntax
C# |
---|
public virtual void SetBuffer( UINT_PTR adrs, int count, bool is_attach ) |
Visual Basic |
---|
Public Overridable Sub SetBuffer ( adrs As UINT_PTR, count As Integer, is_attach As Boolean ) |
Parameters
- adrs
- Type: fvalgcli..::..UINT_PTR
配列の先頭アドレス
- count
- Type: System..::..Int32
要素数 (0~)
- is_attach
- Type: System..::..Boolean
アタッチ指定
Remarks
外部で確保した領域をこのインスタンスに設定します。
現在保有している配列は Clear()()()() で事前に消去されます。
引数 is_attach に指定した値は、IsAttach に設定されます。
処理に失敗した場合は例外を発行します。 例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。
エラーコード:
値 | ErrorCode メンバ | 内容 |
---|---|---|
11 | FVIL.ErrorCode.INVALID_PARAMETER | 引数に指定された値が不正です。 adrs が IntPtr.Zero の時、count が 0 でない場合は受け付けません。 |
Examples
ソースコード:
C# | Copy |
---|---|
using System; using System.Collections.Generic; using System.Text; using fvalgcli; namespace User.SampleCode.Array { public partial class UINT_ARRAY { /// <summary> /// 外部確保の領域設定. /// </summary> [FvPluginExecute] public void SetBuffer() { int countOrg = 10; int countAlloc = 20; int countSet = 15; // 0) 配列の作成. uint[] datas = new uint[countOrg]; for (int i = 0; i < countOrg; i++) { datas[i] = (uint)(i * 10 + i); } // 1) インスタンスの準備と生成. FVIL.UINT_ARRAY src1 = new FVIL.UINT_ARRAY(datas); // 2) 領域の確保. fvalgcli.UINT_PTR adrs = fvalgcli.UINT_PTR.alloc(countAlloc); // 3) 領域の設定. src1.SetBuffer(adrs, countSet); // E) 確認. Assert.IsTrue(adrs == src1.Address, "src1.Address = {0}", src1.Address); Assert.IsTrue(countSet == src1.Count, "src1.Count = {0}", src1.Count); Assert.IsTrue(false == src1.IsAttach, "src1.IsAttach = {0}", src1.IsAttach); } /// <summary> /// 外部確保の領域設定 (アタッチ指定). /// </summary> [FvPluginExecute] public void SetBuffer_IsAttatch_True() { SetBuffer_IsAttatch(true); } /// <summary> /// 外部確保の領域設定 (アタッチ指定). /// </summary> [FvPluginExecute] public void SetBuffer_IsAttatch_False() { SetBuffer_IsAttatch(false); } /// <summary> /// 外部確保の領域設定 (アタッチ指定). /// </summary> public void SetBuffer_IsAttatch(bool is_attach) { int countOrg = 10; int countAlloc = 20; int countSet = 15; // 0) 配列の作成. uint[] datas = new uint[countOrg]; for (int i = 0; i < countOrg; i++) { datas[i] = (uint)(i * 10 + i); } // 1) インスタンスの準備と生成. FVIL.UINT_ARRAY src1 = new FVIL.UINT_ARRAY(datas); // 2) 領域の確保. fvalgcli.UINT_PTR adrs = fvalgcli.UINT_PTR.alloc(countAlloc); // 3) 領域の設定. src1.SetBuffer(adrs, countSet, is_attach); // E) 確認. Assert.IsTrue(is_attach == src1.IsAttach, "src1.IsAttach = {0}", src1.IsAttach); Assert.IsTrue(adrs == src1.Address, "src1.Address = {0}", src1.Address); Assert.IsTrue(countSet == src1.Count, "src1.Count = {0}", src1.Count); } } } |
Visual Basic | Copy |
---|---|
Imports System.Collections.Generic Imports System.Text Imports fvalgcli Namespace SampleCode.Array Public Partial Class UINT_ARRAY ''' <summary> ''' 外部確保の領域設定. ''' </summary> <FvPluginExecute> _ Public Sub SetBuffer() Dim countOrg As Integer = 10 Dim countAlloc As Integer = 20 Dim countSet As Integer = 15 ' 0) 配列の作成. Dim datas As UInteger() = New UInteger(countOrg - 1) {} For i As Integer = 0 To countOrg - 1 datas(i) = CUInt(i * 10 + i) Next ' 1) インスタンスの準備と生成. Dim src1 As New FVIL.UINT_ARRAY(datas) ' 2) 領域の確保. Dim adrs As fvalgcli.UINT_PTR = fvalgcli.UINT_PTR.alloc(countAlloc) ' 3) 領域の設定. src1.SetBuffer(adrs, countSet) ' E) 確認. Assert.IsTrue(adrs = src1.Address, "src1.Address = {0}", src1.Address) Assert.IsTrue(countSet = src1.Count, "src1.Count = {0}", src1.Count) Assert.IsTrue(False = src1.IsAttach, "src1.IsAttach = {0}", src1.IsAttach) End Sub ''' <summary> ''' 外部確保の領域設定 (アタッチ指定). ''' </summary> <FvPluginExecute> _ Public Sub SetBuffer_IsAttatch_True() SetBuffer_IsAttatch(True) End Sub ''' <summary> ''' 外部確保の領域設定 (アタッチ指定). ''' </summary> <FvPluginExecute> _ Public Sub SetBuffer_IsAttatch_False() SetBuffer_IsAttatch(False) End Sub ''' <summary> ''' 外部確保の領域設定 (アタッチ指定). ''' </summary> Public Sub SetBuffer_IsAttatch(is_attach As Boolean) Dim countOrg As Integer = 10 Dim countAlloc As Integer = 20 Dim countSet As Integer = 15 ' 0) 配列の作成. Dim datas As UInteger() = New UInteger(countOrg - 1) {} For i As Integer = 0 To countOrg - 1 datas(i) = CUInt(i * 10 + i) Next ' 1) インスタンスの準備と生成. Dim src1 As New FVIL.UINT_ARRAY(datas) ' 2) 領域の確保. Dim adrs As fvalgcli.UINT_PTR = fvalgcli.UINT_PTR.alloc(countAlloc) ' 3) 領域の設定. src1.SetBuffer(adrs, countSet, is_attach) ' E) 確認. Assert.IsTrue(is_attach = src1.IsAttach, "src1.IsAttach = {0}", src1.IsAttach) Assert.IsTrue(adrs = src1.Address, "src1.Address = {0}", src1.Address) Assert.IsTrue(countSet = src1.Count, "src1.Count = {0}", src1.Count) End Sub End Class End Namespace |
Exceptions
Exception | Condition |
---|---|
FVIL..::..CFviException | この例外の原因については、上記のエラーコード表をご参照ください。 |