How can read data from Kepware server - plc

I would like to development a client app to read data from machine PLC. On this machine there is a bridge pc that have the Kepware server installed, so if I run kepware client demo toolkit I can read the value of machine. So I would like to development a client for read data from this machine.
I have find this program online but I have a problem with library when I try to run it
http://support.automation.siemens.com/WW/llisapi.dll?func=cslib.csinfo&objId=25229521&lang=en&siteid=cseus&aktprim=0&objaction=csview&extranet=standard&viewreg=WW
I see the comunication is on OPC Protocol (OLE for Process Control).
Can we help me?

Download and install QuickOPC 5.23(.NET Framework 3.5 or 4.0) or QuickOPC 5.31(.NET Framework 4.5) from http://opclabs.com/products/quickopc/downloads
Create a VB.NET project in VisualStudio.
Add the reference, OpcLabs.EasyOpcClassic.dll to the project.
Use the following code to read data from Kepware server using VB.NET
Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.DataAccess
Public Class Demand
Private Sub frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReadPLCvalue()
End Sub
Private Sub ReadPLCvalue()
Dim objClient As New EasyDAClient
Dim sValue As Object
Try
sValue = objClient.ReadItemValue(KepwareServerMachineName, KepwareServerID, PLCTagName)
Catch ex As OpcException
End Try
StoreToDB(sValue)
End Sub
Private Sub StoreToDB(ByVal source As Object)
'Database operations to store the value.
End Sub
End Class

Related

Not able to read file from server - on-premise CRM

Trying to read file from server where CRM is installed. When I am reading the file from the server, plugin throws an error "Directory not found".
Entity attachment = new Entity("activitymimeattachment");
FileStream stream = File.OpenRead(fileName);
byte[] byteData = new byte[stream.Length];
stream.Read(byteData, 0, byteData.Length);
stream.Close();
// Encode the data using base64.
string encodedData = System.Convert.ToBase64String(byteData);
attachment["subject"] = "Attachment";
attachment["filename"] = "emailstatement.pdf";
//byte[] fileStream = Encoding.ASCII.GetBytes(fileName);
attachment["body"] = encodedData;
attachment["mimetype"] = #"application\pdf";
attachment["attachmentnumber"] = 1;
attachment["objectid"] = new EntityReference("email", emailguid);
attachment["objecttypecode"] = "email";
service.Create(attachment);
Can anyone help me to read file from server using plugin?
Thank you.
Makes sure your plugin is registered outside of the sandbox (in partial trust). Its an option in the plugin registration tool.
Plug-in isolation, trusts, and statistics
Microsoft Dynamics 365 (online & on-premises) support the execution of
plug-ins and custom workflow activities in an isolated environment. In
this isolated environment, also known as a sandbox, a plug-in or
custom activity can make use of the full power of the Microsoft
Dynamics 365 SDK to access the organization web service. Access to the
file system, system event log, certain network protocols, registry,
and more is prevented in the sandbox.

Side-loaded Windows 8.1 application generates an exception when calling methods of an RESTful Web API

I have developed a Line-of-Business (LOB) Windows 8.1 application for one of our clients. The app was developed in Visual Studio 2015, on my 64-bit Windows 8.1 Enterprise laptop. The application makes use of a RESTful Web API that is running under IIS Express on the same laptop. The IIS Express has been configured to expose the RESTful Web API to the outside world, such that I can make Web API calls with Fiddler from a different machine. My app works just fine when I test it with the VS2015 Simulator, even when I configure it to use the correct IP address of the Web API (not the localhost).
The client wants to deploy this app in production on some DELL tablets that will run Windows 10. I have one of these tablets and it has 64-bit Windows 10 Enterprise on it. When I side-load my app on the tablet, I launch it and I save in its settings the URL for the Web API service. I relaunch the app, but the first call into the Web API fails to complete. I log an exception informing me that "An error occurred while sending the request". The inner exception message is "Unable to connect to the remote server". The line of code that triggers this exception is this one:
HttpResponseMessage response = await WebApiHttpClient.GetAsync("api/user", HttpCompletionOption.ResponseContentRead).ConfigureAwait(continueOnCapturedContext: false);
where the WebApiHttpClient object is a class static member constructed like this:
if (WebApiHttpClient == null)
{
WebApiHttpClient = new HttpClient(WebApiAuthClientHandler)
{
BaseAddress = new Uri(_serviceUri), // _serviceUri is a string that looks like this "http://10.120.5.201:53045"
Timeout = new TimeSpan(0, 0, 150)
};
WebApiHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
The WebApiAuthClientHandler is also a class static member that is instantiated like this:
if (WebApiAuthClientHandler == null)
{
WebApiAuthClientHandler = new HttpClientHandler()
{
Credentials = CredentialCache.DefaultNetworkCredentials,
ClientCertificateOptions = ClientCertificateOption.Automatic
};
}
The exception is triggered about 21 seconds after my call so it can't be a timeout since the timeout is set to 150 seconds.
The Web API is running on my laptop, as I mentioned before and using the node.js iisexpress-proxy tool I managed to expose the local URL to the outside world so that I can make Web API calls using Fiddler running on the tablet.
Also, in my app's Package.appxmanifest/Capabilities I have checked the "Private Networks (Client & Server)".
The Event Viewer does not log any additional information.
Can anyone make a suggestion on why the error is triggered?
TIA,
Eddie
The error message I have in my 3rd comment was caused by the fact that I had Fiddler running at the same time. When running without Fiddler, the application receives a different error, but that will be the subject of a different question here, on StackOverflow.

Agile Classes.jar file

I am using Agile PLM Version: 9.3.0.2 (Build 20). I am on the client side. I'm trying to use Eclipse to interact with Agile's API features. According to the Agile SDK Developer Guide I need both:
AgileAPI.jar
agileclasses.jar
I have the AgileAPI.jar file, but I don't have the agileclasses.jar file.
Any suggestions/links/ methods in which I can obtain this file!
AgileAPI.jar, contains the factories and interfaces used by the Agile EJB on server side.
If you have an Agile instance on a server, you don't need to have agileclasses.jar (unofficial API) but creating an IAgileSession using AgileSessionFactory, all the implementation of interfaces (IChange, IPrograms, IItem. etc) are retrieved using it.
session.getObject(IChange.OBJECT_TYPE, "ChangeNumber123");
where did you find that agileclasses.jar is required?
However, you can find them in the Weblogic Server shared lib folder.
EDIT
Eclipse interacts with an Agile Server using AgileAPI.jar.
String server = "http://myServer:7001/Agile";
HashMap<Integer,String> params = new HashMap<Integer, String>();
AgileSessionFactory instance = AgileSessionFactory.getInstance(server);
params.put(AgileSessionFactory.USERNAME, "myUsername");
params.put(AgileSessionFactory.PASSWORD, "myPassword");
IAgileSession session=instance.createSession(params);
IItem item = (IItem) session.getObject(IItem.OBJECT_TYPE, "ITEMID1234");
item.setValue("Page Two.MYFIELD", "Value");
The example above, connect to an instance of Agile (server) already started up and get the item with number ITEMID1234. Then it sets the value of a field (MYFIELD) with "Value"

Perforce , Perl , how to work with the client

I am new to the Perforce source control and I am trying to build a script that login to the server and get files to the working directory. Now I am able to connect to the server, set the working folder but I can not get the client.
This is the code of the connection to the server
$p4 = new P4;
$p4->SetProg($ScriptName);
$p4->SetVersion($ScriptRevision);
$p4->SetCharset($ENV{P4_CHARSET});
$p4->SetPort ($ENV{P4_IP_AND_PORT});
$p4->SetClient($ENV{P4_CLIENT});
$p4->SetUser($ENV{P4_USER});
$p4->SetPassword($ENV{P4_PWD});
$p4->Connect() or die "blblblblblb" ;
$p4->SetCwd($Working_dir); ## the dir exists
Now I need to create the client. Is this is the way ?
$p4->FetchClient( $ENV{P4_CLIENT} );
I am getting back an object , but the
Runsync command fail with error
Client 'xxxxxx' unknown - use 'client' command to create it
My question is how to create the client in Perl and how to use it in the sync command.
To create the client in P4Perl, you'll need to:
Construct the spec data for the new client, either field-by-field, or by using a template client.
Issue $p4->SaveClient( $clientspec ); with your spec data.
Then, once you've created your client spec that describes your workspace, you'll need to tell P4Perl to use that client spec for your commands: $p4->SetClient( 'my-client-name' );
Then you can run your sync command.

Oracle Instance Client Light (odac 11) and character sets

I am trying to connect to oracle db without full installation of oracle client done on the machine.
I found this helpfull post Using the new ODP.Net to access Oracle from C# with simple deployment but when I try it, I am failed on the next exception:
[Oracle.DataAccess.Client.OracleException ORA-12737: Instant Client Light: unsupported server character set %s at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
...
I tried to Google it up, but find nothing except "Do not use this character set" suggestions.
I occasionally I am working with NLS_LANG "american_america.US8PC437", but it can be different (client environment) character set.
Do you have any idea how can I extend light instance client with character sets resources?
Thank you!
I had the same problem and google says the solution is 'some_big_oracle_package' installation, but I want to keep this away. So simply unpacked all dll files from ODAC112012Xcopy.zip 32bit (xcopy version ONLY). And it works! So I had to found the mysterious dll that pushed it to the next level. The one & only is
oraociei11.dll
On my working-portable solution catalog I have .exe file and 4 dlls:
oci.dll,
Oracle.DataAccess.dll (version
2.112.1.2),
OraOps11w.dll
oraociei11.dll
This stuff works on Win7 x86 & x64 and WinXP x86 (all the systems don't have Oracle or sth installed, pure copy & paste).
Notice that oraociei11.dll weighs 120MB! After compression ~40MB
Tell me if it works for you