From: "Oliver Espeter" on
Hi,
I have problems fetching data from an special database over a com-based sdk.
With VisualBasic it's not a problem,
but the same code doesn't work with php.

First some Data:
- The database system holds high compressed industrial data and is called
OSI-PI. The system itself is under a
comercial license (OSI Soft Inc.).
- The distributor gave us a sdk - fully OO.
- The sdk has to be integrated over COM.
- My 1. testsystem: Windows 2000 Professional Version 5.00.2195 with php
5.2.2
- My 2. testsystem: Windows 2003 Server with php 5.2.4

Here a code-sniplet from me that work:
1 <?php
2 $comObjPi = new COM('PISDK.PISDK');
3 $server = $comObjPi->Servers->Item("123.123.123.123");
4 $server->Open("123.123.123.123;UID=foo;pwd=bar");
5 $point = $server->PIPoints("SINUSOID");
6 echo "\n".$point->Data->SnapShot()->Value."\n";
7 echo "\n".$point->Data->SnapShot()->TimeStamp."\n";
8 ?>

Line 2 makes an object from the sdk. Line 3 and 4 builds up the connection
to the server. Line 5 connects to
an datapoint (PI-Point/Sinosoid is a testpoint). Line 6 and 7 receive the
last value and the last time that are stored
in the point. Everything WORKS FINE.

But when we use some other functions of the sdk, php throws some exceptions:

9 com_load_typelib('PISDK.PISDK');
10 echo "\nTest 1:\n";
11 try{
12 $value = $point->Data->ArcValue(new Variant(mktime(), VT_R8),
rtBefore);
13 }
14 catch(Exception $e){
15 print("\nException Versuch 1 ".$e->getMessage()." TraceString:
".$e->getTraceAsString());
16 }
17
18 echo "\nTest 2:\n";
19 try{
20 $value = $point->Data->ArcValue(variant_date_from_timestamp(mktime()),
rtBefore);
21 }
22 catch(Exception $e){
23 print("\nException Versuch 2 ".$e->getMessage()." TraceString:
".$e->getTraceAsString());
24 }
25
26 $server->Close();
27 ?>

Line 12/20: The function ArcValue is designed for calling archived values
from a pi-point. It needs two values.
First the date/time as Long, Int, String..., nearly each format. The second
value is a constant. We loaded all
of them in Line 9. We tested all types of variant for the first value, but
each time it throws the following exception:

---
Test 1:
Exception Test 1 Parameter 0: Typkonflikt. //Type-Mismatch in the english
version
TraceString: #0 C:\php_pi\pitest.php(12):
variant->ArcValue(Object(variant), 6)
#1 {main}
Test 2:
Exception Test 2 Parameter 0: Typkonflikt.
TraceString: #0 C:\php_pi\pitest.php(20):
variant->ArcValue(Object(variant), 6)
#1 {main}
----

We tested other functions from the sdk. But each time we tried we lose. :-/
Fololowing an example written in
VisualBasic that works fine:

Imports pisdk
Public Class Form1
Private Sub Form1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Click
Dim MySdk As New PISDK.PISDK
Dim pt As PIPoint
Dim v As PIValues
pt = MySdk.Servers.DefaultServer.PIPoints("sinusoid")
v = pt.Data.PlotValues("1-Jan-07", "*", 1000)
MsgBox(v.Count & " Elements")
End Sub
End Class

It receives all datarows for the point "sinusoid" since first Jan and counts
them. This example works with
VisualBasic but it didn't work on php.

Some programmers of OSI-Soft said that all functions takes objects as
parameter so the type-mismatch is a
problem in php. Because of the working VB code I think they are right.

Has anyone a hint for me or a likewise problem with an other
sdk/application?

Regards
Oliver
From: "Oliver Espeter" on
Hi,
I have still the same problem. Because I didn't find a solution, I am
aktualy writing a php extension that wrapps around the needed functions of
the third-party com-sdk.

My plan:
- Connect to the third-party lib throuh COM direcly from my
php-source-files.
- Using all running third-party functions direcly from my php-source-files
without my extension.
- Wrapp the functions "ArcValue" and "PlotValues" with an self-made
extension, so that I can call the specified functions with C.
- Call this self-made functions from my php-source-code (as first parameter
I'll set the reference to the PIPoint)

An code-example in php could be:
1 <?php
2 $comObjPi = new COM('PISDK.PISDK');
3 $server = $comObjPi->Servers->Item("123.123.123.123");
4 $server->Open("123.123.123.123;UID=foo;pwd=bar");
5 $point = $server->PIPoints("SINUSOID");
6 com_load_typelib('PISDK.PISDK');
7 $value = myArcValueFunction($point, mktime(), rtBefore);
8 ?>

But now my problem:
Writing an php extension is not that problem. Including COM-Functions isn't
one too. But using COM from an php extension is new for me. Because I have
to use nmake (or haven't I?) I can't use the "#import' statements:

#import "pisdkcommon.dll" no_namespace
#import "piTimeServer.dll" no_namespace
#import "pisdk.dll" no_namespace

And when I didn't import that third-Party-dlls then nmake throws
compiler-errors because normaly I have to tell PHP that the first parameter
from myArcValueFunction is from type PIPointPtr (defined in one of the
DLLs).

Any suggestions?

--
Mit freundlichen Gr��en / Best Regards

Oliver Espeter


""Oliver Espeter"" <oespeter(a)gravityshock.biz> schrieb im Newsbeitrag
news:DD.EB.08661.04C85474(a)pb1.pair.com...
> Hi,
> I have problems fetching data from an special database over a com-based
> sdk. With VisualBasic it's not a problem,
> but the same code doesn't work with php.
>
> First some Data:
> - The database system holds high compressed industrial data and is called
> OSI-PI. The system itself is under a
> comercial license (OSI Soft Inc.).
> - The distributor gave us a sdk - fully OO.
> - The sdk has to be integrated over COM.
> - My 1. testsystem: Windows 2000 Professional Version 5.00.2195 with php
> 5.2.2
> - My 2. testsystem: Windows 2003 Server with php 5.2.4
>
> Here a code-sniplet from me that work:
> 1 <?php
> 2 $comObjPi = new COM('PISDK.PISDK');
> 3 $server = $comObjPi->Servers->Item("123.123.123.123");
> 4 $server->Open("123.123.123.123;UID=foo;pwd=bar");
> 5 $point = $server->PIPoints("SINUSOID");
> 6 echo "\n".$point->Data->SnapShot()->Value."\n";
> 7 echo "\n".$point->Data->SnapShot()->TimeStamp."\n";
> 8 ?>
>
> Line 2 makes an object from the sdk. Line 3 and 4 builds up the connection
> to the server. Line 5 connects to
> an datapoint (PI-Point/Sinosoid is a testpoint). Line 6 and 7 receive the
> last value and the last time that are stored
> in the point. Everything WORKS FINE.
>
> But when we use some other functions of the sdk, php throws some
> exceptions:
>
> 9 com_load_typelib('PISDK.PISDK');
> 10 echo "\nTest 1:\n";
> 11 try{
> 12 $value = $point->Data->ArcValue(new Variant(mktime(), VT_R8),
> rtBefore);
> 13 }
> 14 catch(Exception $e){
> 15 print("\nException Versuch 1 ".$e->getMessage()." TraceString:
> ".$e->getTraceAsString());
> 16 }
> 17
> 18 echo "\nTest 2:\n";
> 19 try{
> 20 $value =
> $point->Data->ArcValue(variant_date_from_timestamp(mktime()), rtBefore);
> 21 }
> 22 catch(Exception $e){
> 23 print("\nException Versuch 2 ".$e->getMessage()." TraceString:
> ".$e->getTraceAsString());
> 24 }
> 25
> 26 $server->Close();
> 27 ?>
>
> Line 12/20: The function ArcValue is designed for calling archived values
> from a pi-point. It needs two values.
> First the date/time as Long, Int, String..., nearly each format. The
> second value is a constant. We loaded all
> of them in Line 9. We tested all types of variant for the first value, but
> each time it throws the following exception:
>
> ---
> Test 1:
> Exception Test 1 Parameter 0: Typkonflikt. //Type-Mismatch in the english
> version
> TraceString: #0 C:\php_pi\pitest.php(12):
> variant->ArcValue(Object(variant), 6)
> #1 {main}
> Test 2:
> Exception Test 2 Parameter 0: Typkonflikt.
> TraceString: #0 C:\php_pi\pitest.php(20):
> variant->ArcValue(Object(variant), 6)
> #1 {main}
> ----
>
> We tested other functions from the sdk. But each time we tried we lose.
> :-/ Fololowing an example written in
> VisualBasic that works fine:
>
> Imports pisdk
> Public Class Form1
> Private Sub Form1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Click
> Dim MySdk As New PISDK.PISDK
> Dim pt As PIPoint
> Dim v As PIValues
> pt = MySdk.Servers.DefaultServer.PIPoints("sinusoid")
> v = pt.Data.PlotValues("1-Jan-07", "*", 1000)
> MsgBox(v.Count & " Elements")
> End Sub
> End Class
>
> It receives all datarows for the point "sinusoid" since first Jan and
> counts them. This example works with
> VisualBasic but it didn't work on php.
>
> Some programmers of OSI-Soft said that all functions takes objects as
> parameter so the type-mismatch is a
> problem in php. Because of the working VB code I think they are right.
>
> Has anyone a hint for me or a likewise problem with an other
> sdk/application?
>
> Regards
> Oliver
From: Elizabeth Smith on
Oliver Espeter wrote:
> Hi,
> I have still the same problem. Because I didn't find a solution, I am
> aktualy writing a php extension that wrapps around the needed functions of
> the third-party com-sdk.
>
> My plan:
> - Connect to the third-party lib throuh COM direcly from my
> php-source-files.
> - Using all running third-party functions direcly from my php-source-files
> without my extension.
> - Wrapp the functions "ArcValue" and "PlotValues" with an self-made
> extension, so that I can call the specified functions with C.
> - Call this self-made functions from my php-source-code (as first parameter
> I'll set the reference to the PIPoint)
>
> An code-example in php could be:
> 1 <?php
> 2 $comObjPi = new COM('PISDK.PISDK');
> 3 $server = $comObjPi->Servers->Item("123.123.123.123");
> 4 $server->Open("123.123.123.123;UID=foo;pwd=bar");
> 5 $point = $server->PIPoints("SINUSOID");
> 6 com_load_typelib('PISDK.PISDK');
> 7 $value = myArcValueFunction($point, mktime(), rtBefore);
> 8 ?>
>
> But now my problem:
> Writing an php extension is not that problem. Including COM-Functions isn't
> one too. But using COM from an php extension is new for me. Because I have
> to use nmake (or haven't I?) I can't use the "#import' statements:
>
> #import "pisdkcommon.dll" no_namespace
> #import "piTimeServer.dll" no_namespace
> #import "pisdk.dll" no_namespace
>
> And when I didn't import that third-Party-dlls then nmake throws
> compiler-errors because normaly I have to tell PHP that the first parameter
> from myArcValueFunction is from type PIPointPtr (defined in one of the
> DLLs).
>
> Any suggestions?
>

Have you looked at some of the extensions in pecl? I would suggest
linking against the dlls you intend to use and take a gander at the php
extension build system for how to manage that - try the pecl.dev mailing
list for help in the C end of things
From: "Oliver Espeter" on
Thanks for the very (!) fast answer. I'll consult that mail-list as you
recoment.

--
Mit freundlichen Gr��en / Best Regards

Oliver Espeter

---------------------------------
GravityShock- Kraus & Espeter GbR
Tel.: +49 (2301) 9 18 39 33
Fax : +49 (2301) 91 28 96
www : www.GravityShock.biz

"Elizabeth Smith" <emsmith(a)elizabethmariesmith.com> schrieb im Newsbeitrag
news:5D.62.27173.DBD85574(a)pb1.pair.com...
> Oliver Espeter wrote:
>> Hi,
>> I have still the same problem. Because I didn't find a solution, I am
>> aktualy writing a php extension that wrapps around the needed functions
>> of the third-party com-sdk.
>>
>> My plan:
>> - Connect to the third-party lib throuh COM direcly from my
>> php-source-files.
>> - Using all running third-party functions direcly from my
>> php-source-files without my extension.
>> - Wrapp the functions "ArcValue" and "PlotValues" with an self-made
>> extension, so that I can call the specified functions with C.
>> - Call this self-made functions from my php-source-code (as first
>> parameter I'll set the reference to the PIPoint)
>>
>> An code-example in php could be:
>> 1 <?php
>> 2 $comObjPi = new COM('PISDK.PISDK');
>> 3 $server = $comObjPi->Servers->Item("123.123.123.123");
>> 4 $server->Open("123.123.123.123;UID=foo;pwd=bar");
>> 5 $point = $server->PIPoints("SINUSOID");
>> 6 com_load_typelib('PISDK.PISDK');
>> 7 $value = myArcValueFunction($point, mktime(), rtBefore);
>> 8 ?>
>>
>> But now my problem:
>> Writing an php extension is not that problem. Including COM-Functions
>> isn't one too. But using COM from an php extension is new for me. Because
>> I have to use nmake (or haven't I?) I can't use the "#import' statements:
>>
>> #import "pisdkcommon.dll" no_namespace
>> #import "piTimeServer.dll" no_namespace
>> #import "pisdk.dll" no_namespace
>>
>> And when I didn't import that third-Party-dlls then nmake throws
>> compiler-errors because normaly I have to tell PHP that the first
>> parameter from myArcValueFunction is from type PIPointPtr (defined in one
>> of the DLLs).
>>
>> Any suggestions?
>>
>
> Have you looked at some of the extensions in pecl? I would suggest
> linking against the dlls you intend to use and take a gander at the php
> extension build system for how to manage that - try the pecl.dev mailing
> list for help in the C end of things
From: "Oliver Espeter" on
> Hi,
> I have problems fetching data from an special database over a com-based
> sdk. With VisualBasic it's not a problem,
> but the same code doesn't work with php.
>
> First some Data:
> - The database system holds high compressed industrial data and is called
> OSI-PI. The system itself is under a
> comercial license (OSI Soft Inc.).
> - The distributor gave us a sdk - fully OO.
> - The sdk has to be integrated over COM.
> - My 1. testsystem: Windows 2000 Professional Version 5.00.2195 with php
> 5.2.2
> - My 2. testsystem: Windows 2003 Server with php 5.2.4
>
> Here a code-sniplet from me that work:
> 1 <?php
> 2 $comObjPi = new COM('PISDK.PISDK');
> 3 $server = $comObjPi->Servers->Item("123.123.123.123");
> 4 $server->Open("123.123.123.123;UID=foo;pwd=bar");
> 5 $point = $server->PIPoints("SINUSOID");
> 6 echo "\n".$point->Data->SnapShot()->Value."\n";
> 7 echo "\n".$point->Data->SnapShot()->TimeStamp."\n";
> 8 ?>
>
> Line 2 makes an object from the sdk. Line 3 and 4 builds up the connection
> to the server. Line 5 connects to
> an datapoint (PI-Point/Sinosoid is a testpoint). Line 6 and 7 receive the
> last value and the last time that are stored
> in the point. Everything WORKS FINE.
>
> But when we use some other functions of the sdk, php throws some
> exceptions:
>
> 9 com_load_typelib('PISDK.PISDK');
> 10 echo "\nTest 1:\n";
> 11 try{
> 12 $value = $point->Data->ArcValue(new Variant(mktime(), VT_R8),
> rtBefore);
> 13 }
> 14 catch(Exception $e){
> 15 print("\nException Versuch 1 ".$e->getMessage()." TraceString:
> ".$e->getTraceAsString());
> 16 }
> 17
> 18 echo "\nTest 2:\n";
> 19 try{
> 20 $value =
> $point->Data->ArcValue(variant_date_from_timestamp(mktime()), rtBefore);
> 21 }
> 22 catch(Exception $e){
> 23 print("\nException Versuch 2 ".$e->getMessage()." TraceString:
> ".$e->getTraceAsString());
> 24 }
> 25
> 26 $server->Close();
> 27 ?>
>
> Line 12/20: The function ArcValue is designed for calling archived values
> from a pi-point. It needs two values.
> First the date/time as Long, Int, String..., nearly each format. The
> second value is a constant. We loaded all
> of them in Line 9. We tested all types of variant for the first value, but
> each time it throws the following exception:
>
> ---
> Test 1:
> Exception Test 1 Parameter 0: Typkonflikt. //Type-Mismatch in the english
> version
> TraceString: #0 C:\php_pi\pitest.php(12):
> variant->ArcValue(Object(variant), 6)
> #1 {main}
> Test 2:
> Exception Test 2 Parameter 0: Typkonflikt.
> TraceString: #0 C:\php_pi\pitest.php(20):
> variant->ArcValue(Object(variant), 6)
> #1 {main}
> ----
>
> We tested other functions from the sdk. But each time we tried we lose.
> :-/ Fololowing an example written in
> VisualBasic that works fine:
>
> Imports pisdk
> Public Class Form1
> Private Sub Form1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Click
> Dim MySdk As New PISDK.PISDK
> Dim pt As PIPoint
> Dim v As PIValues
> pt = MySdk.Servers.DefaultServer.PIPoints("sinusoid")
> v = pt.Data.PlotValues("1-Jan-07", "*", 1000)
> MsgBox(v.Count & " Elements")
> End Sub
> End Class
>
> It receives all datarows for the point "sinusoid" since first Jan and
> counts them. This example works with
> VisualBasic but it didn't work on php.
>
> Some programmers of OSI-Soft said that all functions takes objects as
> parameter so the type-mismatch is a
> problem in php. Because of the working VB code I think they are right.
>
> Has anyone a hint for me or a likewise problem with an other
> sdk/application?
>
> Regards
> Oliver

I've reported the problem as php-bug.
http://bugs.php.net/43521

--
Mit freundlichen Gr��en / Best Regards

Oliver Espeter