Standalone application generated by matlab deploytool/compilation with OPC fails in host system - matlab

My matlab application communicates with dymola software (for dynamic modeling/simulation/calculation) by giving inputs and fetching outputs. Everything working fine in Matlab command window. The standalone application developed in the matlab (using Application compiler) works fine in the same system as the one it was developed in.
Once I install the application (with matlab runtime) into an host system without the full matlab installation, The OPC code fails.
* Code developed/compiled in : Windows 10 Pro,
* deployed to/Host system : Windows 10 Pro,
* Matlab version 2017b
* OPC toolbox version 4.0.4
* Matlab runtime 9.3
The OPC code snippet is as follows:
%% File: SetupOPCDA_MatlabDymolaConnection()
try
%opcregister('install')
hostInfo = opcserverinfo('localhost');
disp(hostInfo.ServerID);
da = opcda('localhost','Dymosim.OPCServer.1');
% Connect to Dymola OPC server
connect(da);
grp = addgroup(da);
ns = getnamespace(da);
catch Err % line 33
The below given outputs are from running the generated exe file from command line in the host system.
Its failing with error:
OPC Foundation Core Components not installed. Run OPCREGISTER to install the OPC Foundation Core Components.
On uncommenting the line opcregister('install')
I'm getting the following error (Please note I'm running the exe from commandline):
Setting OPC connection...Warning: OPC Core Components are already installed. Reinstalling may require a repair of the Core Components.
Continuing this operation will modify any OPC Foundation files already installed.
MATLAB may shut down, and a system reboot may occur.
Type 'Yes' (exactly as shown) to install the OPC Foundation files
Confirmation string: Yes
'Yes' is not recognized as an internal or external command,
operable program or batch file.
Operation cancelled by user.
On giving the line as: opcregister('install','-silent')
Error:
Warning: OPC Core Components are already installed. Reinstalling may require a repair of the Core Components.
TWarning: Installation was not successful. Exit code was 1619.
OPC Foundation Core Components not installed. Run OPCREGISTER to install the OPC Foundation Core Components.
To compare, This is the output I get in my system, the one in which the code was developed and compiled:
OPC working fine, Gives server names as outputs
'Matrikon.OPC.Simulation.1' 'Dymosim.OPCServer.1'
It works fine in the developer system, but it fails in host system.

I was able to solve the problem by installing the OPC core components manually.
Installing them before running the Matlab exe, solved the problem.
P.S. You need to create an account before downloading the OPC core components.

Related

run a matlab script on a remote server

I have ssh access to a remote linux server and no admin rights. The server does not have matlab installed and I need to run a few matlab scripts. Are there any ways by which I can run these scripts on the server ? I read a few links saying to download the matlab compiler or runtime but they do not have detailed instructions on how to proceed and even less so pertaining to remote servers.
Generally there are three options
install MATLAB (it is available for Linux but you need to have admin rights..)
box your scripts as distributables with the Application Compiler (as #UnbearableLigthness already mentioned). You will need to install the MATLAB Runtime on your Linux server to run those applications. However, you can package the runtime in the application (bulletpoint 3).
create C code with the MATLAB Coder and compile it on your Linux server. This requires no installation but does not support all functions (e.g. most constrained optimization algorithms are not supported)

Include drivers with application installation

I have created an application in C# that relies on a specific driver (a custom virtual hid driver based on VMulti).
Currently, I have everything working and I want to combine both the application and driver into one installation package. As of right now, my application part has a .exe file and a .dll file. My driver has an .inf and .sys file, hidkmdf.sys, and WdfCoInstaller01009.dll (this dll is from the WDK). I am not able to install the driver through the traditional method of right-clicking the inf and clicking install. Instead, I use devcon to install it (command is "install inffile.inf hardwareid")
I tried using InstallShield LE, but I am only able to install the application, not the driver. After doing some searching, I found people using DIFxAPP to create the installation framework for drivers, however, I am not sure if this can be integrated into InstallShield so that the driver is installed during the application installation process.
So my main question is: What is the best and simplest method for combining application and driver installation into one package (meaning the setup.exe will install both the driver and the application)?
I am very new to driver development and application deployment, so any suggestions are welcome.
Thank You
EDIT: It is preferred that the solution does not require any paid tools.
Acctually, exists a many ways to implement this which depends on your Windows Installers skills.
You didn't specify target OSes for your application, that's why can I give you some ways:
PnpUtil.exe internal Windows 7 utility (only for Windows 7)
DPInst.exe included to WDK
DifXAPI merge module.
You can install drivers with help of all these utils via Custom Actions.
NOTE: That your driver SHOULD BE signed, otherwise you will receive error during silent installation.

Visual C++ Runtime on Network Location

I have a MATLAB executable that I am trying to deploy within my company, but I don't want people to need to install a bunch of stuff. The executable is saved to a network location and I want them to just run it. I have MATLAB Compiler Runtime (MCR) set up on the network, but now I'm running into issues with Visual C++ Runtime (VC++R) saying the application isn't installed properly. Is there a way to install VC++R to a network location. (People don't have permissions to install things, which is why I want to get away from having to install MCR and VC++R.)
From my experience with deployed MATLAB using MCR through r2013a, MCR must always be installed locally.
This does present an issue with thin clients.
A workaround would be to deploy the executable as a remote-ly accessible service, either a Windows Service or other endpoint. This was my solution

Deploying linux CUDA app

I've compiled a cu program on my laptop, using NVIDIA CUDA 5 toolkit. A very basic interface, using only terminal output. Then I went on to test how it runs on my desktop PC (both have Ubuntu 12.04 LTS installed).
On the desktop PC I get this error message:
error while loading shared libraries: libcudart.so.5.0: cannot open shared object file: No such file or directory
Ok, I get it, some libs are not installed. But do I really need to install CUDA toolkit on every PC where I'd want my compiled code to run?
To deploy a CUDA runtime API application on linux you only need to do two things:
Make sure that the machine in question has a CUDA compatible card and a minimum driver version which matches the CUDA Toolkit you used to build the application (you can find information regarding both of these in the release notes of the toolkit)
Distribute the runtime library (so cudart.so) that you built the application against with the executable. If you used any other libraries from the toolkit (like CUBLAS, CUFFT, CUSPARSE, etc) you need to inlcude those too. The CUDA runtime library is versioned and you have to have the libraries which match the toolkit you are building with. You may need to use the LD_LIBRARY_PATH environment variable to ensure that the correct versions of the libraries are found by the link loader. Often a simple shell script which acts the canonical application, settings LD_LIBRARY_PATH variable and running the built executable is the best way to do this.
If you get those two things right, it should just work.

clGetPlatformIDs error -1001 when called in PostgreSQL UDF

I'm trying to write an OpenCL function that would be executed inside PostgreSQL. To do this i create DLL from my OpenCL code and link it to postgres using User-Defined Function mechanism. Everything goes well until clGetPlatformIDs is called. Function returns error -1001, which I read that indicates problem with finding OpenCL drivers.
I've tried to compile the same code(i had to remove some postgres magic) to exe and runed it with success - all platforms were found correctly, so I assume that i have correctly set up SDK and drivers.
I am runing PostgreSQL 9.1 on windows 7 x64. I am also using Nvidia CUDA SDK 4.2 with Visual Studio 2010 and running my code on GeForce GTS 450.
It's MSFT's problem with Windows, Services, GPUs, Security and device drivers.
You can't run PostgreSQL as a service on Windows AND see any GPUs. You are hitting Session O Isolation which does NOT allow any 'graphics' device access from a Windows Service. You can start PostgreSQL as a process (not a service) or put the server on Linux.
See http://www.scribd.com/doc/58343489/Windows-Session-0-Isolation-Impact-on-GPU-as-Service
Also there are other important reasons to run on Linux, as Windows will want to reboot your GPU if the screen is not accessed before the timeout period. See
http://msdn.microsoft.com/en-us/library/windows/hardware/ff570088%28v=vs.85%29.aspx
NVida have a non-graphics GPU device driver for specific Tesla cards on Windows. These cards don't have any video output. So they aren't considered to be graphics device drivers.
Maybe the libraries try to locate the SDK using some environment-variables and the environment is not inherited inside the PostegreSQL context.
So try to dump the environment from your two codes and check if any OpenCL/Cuda variables is available in your standalone program and missing in your PostegreSQL UDF.