Can't call some constructors or methods
wesnm opened this issue · 0 comments
wesnm commented
Trying to interface with the OSI .NET AFSDK (https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/1a02af4c-1bec-4804-a9ef-3c7300f5e2fc.htm).
I can create the base objects ("Server", "PIPoint"):
> server
An object of class "cobjRef"
Slot "clrobj":
<pointer: 0x0000000061f154b0>
Slot "clrtype":
[1] "OSIsoft.AF.PI.PIServer"
> tag <- clrCallStatic("OSIsoft.AF.PI.PIPoint", "FindPIPoint", server, "MyPoint")
> tag
An object of class "cobjRef"
Slot "clrobj":
<pointer: 0x00000000623ac1d0>
Slot "clrtype":
[1] "OSIsoft.AF.PI.PIPoint"
Getting a property of the tag also works as expected:
> clrGetProperties(tag)
[1] "Future" "ID" "IsResolved" "Name" "PointClass" "PointType" "Server" "Step"
> clrGet(tag, "Step")
[1] FALSE
However, I cannot call certain constructors:
> clrNew("OSIsoft.AF.Time.AFTime", "2017-01-01")
Error in clrNew("OSIsoft.AF.Time.AFTime", "2017-01-01") :
Failure in rclr_ms_call_static_method, but could not retrieve an error message
And then various properties of objects do not work:
value <- clrCall(tag, "Snapshot")
> value
An object of class "cobjRef"
Slot "clrobj":
<pointer: 0x00000000623ab470>
Slot "clrtype":
[1] "OSIsoft.AF.Asset.AFValue"
> clrGetProperties(value)
[1] "AdditionalInfo" "Annotated" "Attribute" "IsGood" "PIPoint" "Questionable" "Status"
[8] "Substituted" "Timestamp" "UOM" "Value" "ValueType" "ValueTypeCode"
> clrGet(value, "Value")
Error in clrCallStatic(clrFacadeTypeName, "GetFieldOrProperty", objOrType, :
Type: System.InvalidCastException
Message: Unable to cast object of type 'System.Double' to type 'System.Double[]'.
Method: RDotNet.SymbolicExpression ConvertArrayDouble(System.Object)
Stack trace:
at Rclr.RDotNetDataConverter.ConvertArrayDouble(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 395
at Rclr.RDotNetDataConverter.TryConvertToSexp(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 320
at Rclr.RDotNetDataConverter.ConvertToR(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 220
at Rclr.ClrFacade.marshallDataToR(Object obj, Boolean tryUseConverter) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\ClrFacade.cs:line 684
at Rclr.ClrFacade.CallStaticMethod(String typename,
> clrGet(value, "Timestamp")
Error in (function () : Failure in rclr_ms_get_current_object_direct
Error in clrCallStatic(clrFacadeTypeName, "GetFieldOrProperty", objOrType, :
Type: RDotNet.EvaluationException
Message: Error in (function () : Failure in rclr_ms_get_current_object_direct
Method: RDotNet.ProtectedPointer evaluateCall(IntPtr)
Stack trace:
at RDotNet.Function.evaluateCall(IntPtr call)
at RDotNet.Function.createCallAndEvaluate(IntPtr argument)
at Rclr.RDotNetDataConverter.CreateClrObj(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 603
at Rclr.RDotNetDataConverter.TryConvertToSexp(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 320
at Rclr.RDotNetDataConverter.ConvertToR(Object obj) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\src\ClrFacade\RDotNetDataConverter.cs:line 220
at Rclr.ClrFacade.marshallDataToR(Object obj, Boolean tryUseConverter) in c:\Users\per202\AppData\Local\Temp\RtmpuMBMYA\R.INSTALL2164365a3840\rClr\sr
A simple method does work:
> clrCall(value, "ValueAsDouble")
[1] 28.30062