Search Results

Search found 2164 results on 87 pages for 'irm wrapper'.

Page 3/87 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C# serial port driver wrapper class code and concept quality

    - by Ruben Trancoso
    Hi folks, Would like to know from all you guys what you think about my Serial Wrapper class. Had be a while I've beem working with serial port but never shared the code what somekind make closed to my very own vision. Would like to know if it's a good/bad approach, if the interface is enough and what more you see on it. I know that Stackoverflow is for question but at the same time there's a lot of very good skilled people here and share code and opinion can also bennefit everybody, it's why I decided to post it anyway. thanks! using System.Text; using System.IO; using System.IO.Ports; using System; namespace Driver { class SerialSingleton { // The singleton instance reference private static SerialSingleton instance = null; // System's serial port interface private SerialPort serial; // Current com port identifier private string comPort = null; // Configuration parameters private int confBaudRate; private int confDataBits; private StopBits confStopBits; private Parity confParityControl; ASCIIEncoding encoding = new ASCIIEncoding(); // ================================================================================== // Constructors public static SerialSingleton getInstance() { if (instance == null) { instance = new SerialSingleton(); } return instance; } private SerialSingleton() { serial = new SerialPort(); } // =================================================================================== // Setup Methods public string ComPort { get { return comPort; } set { if (value == null) { throw new SerialException("Serial port name canot be null."); } if (nameIsComm(value)) { close(); comPort = value; } else { throw new SerialException("Serial Port '" + value + "' is not a valid com port."); } } } public void setSerial(string baudRate, int dataBits, StopBits stopBits, Parity parityControl) { if (baudRate == null) { throw new SerialException("Baud rate cannot be null"); } string[] baudRateRef = { "300", "600", "1200", "1800", "2400", "3600", "4800", "7200", "9600", "14400", "19200", "28800", "38400", "57600", "115200" }; int confBaudRate; if (findString(baudRateRef, baudRate) != -1) { confBaudRate = System.Convert.ToInt32(baudRate); } else { throw new SerialException("Baurate parameter invalid."); } int confDataBits; switch (dataBits) { case 5: confDataBits = 5; break; case 6: confDataBits = 6; break; case 7: confDataBits = 7; break; case 8: confDataBits = 8; break; default: throw new SerialException("Databits parameter invalid"); } if (stopBits == StopBits.None) { throw new SerialException("StopBits parameter cannot be NONE"); } this.confBaudRate = confBaudRate; this.confDataBits = confDataBits; this.confStopBits = stopBits; this.confParityControl = parityControl; } // ================================================================================== public string[] PortList { get { return SerialPort.GetPortNames(); } } public int PortCount { get { return SerialPort.GetPortNames().Length; } } // ================================================================================== // Open/Close Methods public void open() { open(comPort); } private void open(string comPort) { if (isOpen()) { throw new SerialException("Serial Port is Already open"); } else { if (comPort == null) { throw new SerialException("Serial Port not defined. Cannot open"); } bool found = false; if (nameIsComm(comPort)) { string portId; string[] portList = SerialPort.GetPortNames(); for (int i = 0; i < portList.Length; i++) { portId = (portList[i]); if (portId.Equals(comPort)) { found = true; break; } } } else { throw new SerialException("The com port identifier '" + comPort + "' is not a valid serial port identifier"); } if (!found) { throw new SerialException("Serial port '" + comPort + "' not found"); } serial.PortName = comPort; try { serial.Open(); } catch (UnauthorizedAccessException uaex) { throw new SerialException("Cannot open a serial port in use by another application", uaex); } try { serial.BaudRate = confBaudRate; serial.DataBits = confDataBits; serial.Parity = confParityControl; serial.StopBits = confStopBits; } catch (Exception e) { throw new SerialException("Serial port parameter invalid for '" + comPort + "'.\n" + e.Message, e); } } } public void close() { if (serial.IsOpen) { serial.Close(); } } // =================================================================================== // Auxiliary private Methods private int findString(string[] set, string search) { if (set != null) { for (int i = 0; i < set.Length; i++) { if (set[i].Equals(search)) { return i; } } } return -1; } private bool nameIsComm(string name) { int comNumber; int.TryParse(name.Substring(3), out comNumber); if (name.Substring(0, 3).Equals("COM")) { if (comNumber > -1 && comNumber < 256) { return true; } } return false; } // ================================================================================= // Device state Methods public bool isOpen() { return serial.IsOpen; } public bool hasData() { int amount = serial.BytesToRead; if (amount > 0) { return true; } else { return false; } } // ================================================================================== // Input Methods public char getChar() { int data = serial.ReadByte(); return (char)data; } public int getBytes(ref byte[] b) { int size = b.Length; char c; int counter = 0; for (counter = 0; counter < size; counter++) { if (tryGetChar(out c)) { b[counter] = (byte)c; } else { break; } } return counter; } public string getStringUntil(char x) { char c; string response = ""; while (tryGetChar(out c)) { response = response + c; if (c == x) { break; } } return response; } public bool tryGetChar(out char c) { c = (char)0x00; byte[] b = new byte[1]; long to = 10; long ft = System.Environment.TickCount + to; while (System.Environment.TickCount < ft) { if (hasData()) { int data = serial.ReadByte(); c = (char)data; return true; } } return false; } // ================================================================================ // Output Methods public void sendString(string data) { byte[] bytes = encoding.GetBytes(data); serial.Write(bytes, 0, bytes.Length); } public void sendChar(char c) { char[] data = new char[1]; data[0] = c; serial.Write(data, 0, 1); } public void sendBytes(byte[] data) { serial.Write(data, 0, data.Length); } public void clearBuffer() { if (serial.IsOpen) { serial.DiscardInBuffer(); serial.DiscardOutBuffer(); } } } }

    Read the article

  • HDF5 .Net wrapper

    - by UshaP
    I'm getting ( http://www.hdfgroup.org/projects/hdf.net/) The specified module could not be found. (Exception from HRESULT: 0x8007007E) from the dependency walker i'm seeing that SZLIBDLL.DLL is missing i tried to download it from random place but then i got another error. Does any one had that problem? i tried also vs2005 and vs2008 Thanks, Pini.

    Read the article

  • C++ wrapper for posix and linux specific functions

    - by Libzajc
    Hi Do you know about any good library wrapping posix and linux functions and structures ( eg. sockets or file descriptors ) into C++ classes? For example I'm thinking about a base FileDescriptor class and some inheriting classes ( unix sockets etc ) with methods like write, read or even some syscalls ( sendfile, splice ) - all throwing exceptions instead of setting errno. Or some shared memory class etc. I can't seem to find anything like that and by now I consider writing it myself, as I often have to write a C++ app for linux and either use C functions ( painful error checking ), or wrap them myself every time.

    Read the article

  • Wrapper around bash, control STDIN and STDOUT

    - by blinry
    I would like to talk to a interactive bash process. Here is an example, so you know what I want to archieve: Program starts a new bash process. User types "ls" into my program. Program sends this command to the bash process. Program reads all available output of the bash (including the prompt) and displays it back to the user. GOTO 1 As you can guess, there is much room for nifty manipulations here and there... ;-) It would be wonderful if this also worked for subprocesses (started by the bash process) and curses-based programs. I would like to implement this functionality in Ruby, and already have experimented with IO.popen, but strange things happen. You are also welcome to do this in other languages.

    Read the article

  • Generate Info (wrapper) Class from stored procedure

    - by Adem
    Hello everybody I am in a crucial project and I am trying to speed up the development phase by using codesmith for generating the business class DAL and info class for the tables of my project. There are about 50 tables with relationships parent child many to many and for retrieving data I have to code several inner joins in stored procedures. I have to combine fields from many tables and this makes working with the info class difficult. Is there anyway to generate info class from stored procedures or to be more exact is there a way to parse the result set of the stored procedure and to generate the info class with properties for every column in that result set. Please if anyone can give me some advice and tell me how to achieve this. Best Regards

    Read the article

  • Possible apache/mysql/php wrapper?

    - by MrStatic
    I was tasked with writing a smallish program for data input and manipulation. My language of choice happens to be PHP. I have written out the program/site it all works fine is easily portable and everything but have one question. Is there anyway to wrap up apache/mysql/php into a bundle of one exe? I know of MoWes Portable and other options but I am looking to basically wrap everything up into a single exe without much fuss to the end user. My target users are very low on the computer savvy scale. I am trying to avoid a batch file for launching and don't really want them able to shutdown one part on accident and not another (IE shut off mysql but leave apache on).

    Read the article

  • Avoiding stack overflows in wrapper DLLs

    - by peachykeen
    I have a program to which I'm adding fullscreen post-processing effects. I do not have the source for the program (it's proprietary, although a developer did send me a copy of the debug symbols, .map format). I have the code for the effects written and working, no problems. My issue now is linking the two. I've tried two methods so far: Use Detours to modify the original program's import table. This works great and is guaranteed to be stable, but the user's I've talked to aren't comfortable with it, it requires installation (beyond extracting an archive), and there's some question if patching the program with Detours is valid under the terms of the EULA. So, that option is out. The other option is the traditional DLL-replacement. I've wrapped OpenGL (opengl32.dll), and I need the program to load my DLL instead of the system copy (just drop it in the program folder with the right name, that's easy). I then need my DLL to load the Cg framework and runtime (which relies on OpenGL) and a few other things. When Cg loads, it calls some of my functions, which call Cg functions, and I tend to get stack overflows and infinite loops. I need to be able to either include the Cg DLLs in a subdirectory and still use their functions (not sure if it's possible to have my DLLs import table point to a DLL in a subdirectory) or I need to dynamically link them (which I'd rather not do, just to simplify the build process), something to force them to refer to the system's file (not my custom replacement). The entire chain is: Program loads DLL A (named opengl32.dll). DLL A loads Cg.dll and dynamically links (GetProcAddress) to sysdir/opengl32.dll. I now need Cg.dll to also refer to sysdir/opengl32.dll, not DLL A. How would this be done? Edit: How would this be done easily without using GetProcAddress? If nothing else works, I'm willing to fall back to that, but I'd rather not if at all possible. Edit2: I just stumbled across the function SetDllDirectory in the MSDN docs (on a totally unrelated search). At first glance, that looks like what I need. Is that right, or am I misjudging? (off to test it now) Edit3: I've solved this problem by doing thing a bit differently. Instead of dropping an OpenGL32.dll, I've renamed my DLL to DInput.dll. Not only does it have the advantage of having to export one function instead of well over 120 (for the program, Cg, and GLEW), I don't have to worry about functions running back in (I can link to OpenGL as usual). To get into the calls I need to intercept, I'm using Detours. All in all, it works much better. This question, though, is still an interesting problem (and hopefully will be useful for anyone else trying to do crazy things in the future). Both the answers are good, so I'm not sure yet which to pick...

    Read the article

  • Using a php://memory wrapper causes errors...

    - by HorusKol
    I'm trying to extend the PHP mailer class from Worx by adding a method which allows me to add attachments using string data rather than path to the file. I came up with something like this: public function addAttachmentString($string, $name='', $encoding = 'base64', $type = 'application/octet-stream') { $path = 'php://memory/' . md5(microtime()); $file = fopen($path, 'w'); fwrite($file, $string); fclose($file); $this->AddAttachment($path, $name, $encoding, $type); } However, all I get is a PHP warning: PHP Warning: fopen() [<a href='function.fopen'>function.fopen</a>]: Invalid php:// URL specified There aren't any decent examples with the original documentation, but I've found a couple around the internet (including one here on SO), and my usage appears correct according to them. Has anyone had any success with using this? My alternative is to create a temporary file and clean up - but that will mean having to write to disc, and this function will be used as part of a large batch process and I want to avoid slow disc operations (old server) where possible. This is only a short file but has different information for each person the script emails.

    Read the article

  • pageTest C# wrapper

    - by Cmachine
    Hi everyone, I would like to obtain the results retrieved from pageTest execution (core @ CVS) from a C# project (library or console). pageTest source code shows a dynamic library project (generating a DLL file) and also an application project (generating an EXE file). Do anybody have previous experience related to this issue? Any tips or recommendations? Thanks in advance for your response. Regards

    Read the article

  • Best wrapper for simultaneous API requests?

    - by bluebit
    I am looking for the easiest, simplest way to access web APIs that return either JSON or XML, with concurrent requests. For example, I would like to call the twitter search API and return 5 pages of results at the same time (5 requests). The results should ideally be integrated and returned in one array of hashes. I have about 15 APIs that I will be using, and already have code to access them individually (using simple a NET HTTP request) and parse them, but I need to make these requests concurrent in the easiest way possible. Additionally, any error handling for JSON/XML parsing is a bonus.

    Read the article

  • Renault under threat from industrial espionage, intellectual property the target

    - by Simon Thorpe
    Last year we saw news of both General Motors and Ford losing a significant amount of valuable information to competitors overseas. Within weeks of the turn of 2011 we see the European car manufacturer, Renault, also suffering. In a recent news report, French Industry Minister Eric Besson warned the country was facing "economic war" and referenced a serious case of espionage which concerns information pertaining to the development of electric cars. Renault senior vice president Christian Husson told the AFP news agency that the people concerned were in a "particularly strategic position" in the company. An investigation had uncovered a "body of evidence which shows that the actions of these three colleagues were contrary to the ethics of Renault and knowingly and deliberately placed at risk the company's assets", Mr Husson said. A source told Reuters on Wednesday the company is worried its flagship electric vehicle program, in which Renault with its partner Nissan is investing 4 billion euros ($5.3 billion), might be threatened. This casts a shadow over the estimated losses of Ford ($50 million) and General Motors ($40 million). One executive in the corporate intelligence-gathering industry, who spoke on condition of anonymity, said: "It's really difficult to say it's a case of corporate espionage ... It can be carelessness." He cited a hypothetical example of an enthusiastic employee giving away too much information about his job on an online forum. While information has always been passed and leaked, inadvertently or on purpose, the rise of the Internet and social media means corporate spies or careless employees are now more likely to be found out, he added. We are seeing more and more examples of where companies like these need to invest in technologies such as Oracle IRM to ensure such important information can be kept under control. It isn't just the recent release of information into the public domain via the Wikileaks website that is of concern, but also the increasing threats of industrial espionage in cases such as these. Information rights management doesn't totally remove the threat, but abilities to control documents no matter where they exist certainly increases the capabilities significantly. Every single time someone opens a sealed document the IRM system audits the activity. This makes identifying a potential source for a leak much easier when you have an absolute record of every person who's had access to the documents. Oracle IRM can also help with accidental or careless loss. Often people use very sensitive information all the time and forget the importance of handling it correctly. With the ability to protect the information from screen shots and prevent people copy and pasting document information into social networks and other, unsecured documents, Oracle IRM brings a totally new level of information security that would have a significant impact on reducing the risk these organizations face of losing their most valuable information.

    Read the article

  • What is a "wrapper" program?

    - by user6950
    Where I work, employees use a third-party desktop program for their clients. This program saves data to a flat file. My colleague wants to write a Java program that uploads that flat file to a remote server, opens the desktop program when the flat file is downloaded from a Web site, and checks if the desktop program is running or not by looking at the Windows processes. He keeps calling this helper/utility program a "wrapper." But it doesn't wrap anything! I tried to clear it up with him, but he said, "Well, I call it a wrapper." He now has everyone in the company calling it a "wrapper." What would you call it? I say that it's a helper program or utility program.

    Read the article

  • How to use cyg-wrapper to fork a new tab in win32 gvim

    - by Peter Nore
    I would like to set up an alias in my cygwin .bashrc that translates pathnames unix-to-dos and passes them to windows gvim in a new tab of an existing instance. I am trying to use Luc Hermitte's cyg-wrapper script for running native win32 applications from Cygwin as per this vim tip. Luc's example of how to use his script is: alias vi= 'cyg-wrapper.sh "C:/Progra~1/Edition/vim/vim63/gvim.exe" --binary-opt=-c,--cmd,-T,-t,--servername,--remote-send,--remote-expr' I do not understand this example because most of these vim parameters (-c,--cmd,--servername,--remote-send,--remote-expr, etc) require more information, and I have not found any example of how to supply the additional information to cyg-wrapper.sh. For example, calling C:/Progra~1/Edition/vim/vim63/gvim.exe --servername=GVIM --remote-tab-silent file1 & will open file1 in a new tab of existing (or non existing) instance GVIM, but calling gvim --servername accomplishes nothing on its own. Unfortunately, though, the corresponding cyg-wrapper phrase does not work: cyg-wrapper.sh "C:/Progra~1/Edition/vim/vim63/gvim.exe" --binary-opt=--servername=GVIM,--remote-tab-silent --fork=2 file1 If ran twice, this actually opens up two instances of gvim; it is as if the servername 'GVIM' is being stripped and ignored. How do you supply a servername to gvim --servername or a .vimrc to gvim -u using cyg-wrapper.sh? Furthermore, why is it that programs must be passed to cyg-wrapper.sh in the relatively obscure "mixed form?" For example, if I try cyg-wrapper.sh "/cygdrive/c/path/to/GVimPortable.exe" --binary-opt=--servername=GVIM,--remote-tab-silent --fork=2 I get "Invalid switch - "/cygdrive"." See also: getting-gvim-to-automatically-translate-a-cygwin-path alias-to-open-gvim-cream-version-from-cygwin-shell

    Read the article

  • C#.Net Calling a C++ DLL

    - by hayer
    Hi I got a DLL(without the sourcecode) which exports like this: ?ReceiveCoreDataPtr@@YAXPAX@Z ?xenoAddRigidBodyAngularImpulse@@YAXHMMM@Z ?xenoAddRigidBodyForce@@YAXHMMM@Z ?xenoAddRigidBodyForce@@YAXHMMMMMM@Z ?xenoAddRigidBodyLinearImpulse@@YAXHMMM@Z ?xenoAddRigidBodyPointImpulse@@YAXHMMMMMM@Z ?xenoAddRigidBodyTorque@@YAXHMMM@Z ?xenoCharacterControllerCrouch@@YAXH@Z ?xenoCharacterControllerJump@@YAXH@Z ?xenoCharacterDisable@@YAXH@Z ?xenoCharacterEnable@@YAXH@Z ?xenoDeleteRigidBody@@YAXH@Z ?xenoEnd@@YAXXZ ?xenoGetCameraFOV@@YAKH@Z ?xenoGetCameraPointX@@YAKH@Z ?xenoGetCameraPointY@@YAKH@Z ?xenoGetCameraPointZ@@YAKH@Z ?xenoGetCameraPositionX@@YAKH@Z ?xenoGetCameraPositionY@@YAKH@Z ?xenoGetCameraPositionZ@@YAKH@Z ?xenoGetCharacterControllerHeadPosition@@YAKH@Z ?xenoGetCharacterControllerPositionX@@YAKH@Z ?xenoGetCharacterControllerPositionY@@YAKH@Z ?xenoGetCharacterControllerPositionZ@@YAKH@Z ?xenoGetCharacterControllerRotation@@YAKH@Z ?xenoGetRigidBodyAllowedPenetrationDepth@@YAKH@Z ?xenoGetRigidBodyAngularDamping@@YAKH@Z ?xenoGetRigidBodyAngularVelocityX@@YAKH@Z ?xenoGetRigidBodyAngularVelocityY@@YAKH@Z ?xenoGetRigidBodyAngularVelocityZ@@YAKH@Z ?xenoGetRigidBodyFriction@@YAKH@Z ?xenoGetRigidBodyGravityFactor@@YAKH@Z ?xenoGetRigidBodyLinearDamping@@YAKH@Z ?xenoGetRigidBodyLinearVelocityX@@YAKH@Z ?xenoGetRigidBodyLinearVelocityY@@YAKH@Z ?xenoGetRigidBodyLinearVelocityZ@@YAKH@Z ?xenoGetRigidBodyMass@@YAKH@Z ?xenoGetRigidBodyMaxAngularVelocity@@YAKH@Z ?xenoGetRigidBodyMaxLinearVelocity@@YAKH@Z ?xenoGetRigidBodyPointVelocityX@@YAKHMMM@Z ?xenoGetRigidBodyPointVelocityY@@YAKHMMM@Z ?xenoGetRigidBodyPointVelocityZ@@YAKHMMM@Z ?xenoGetRigidBodyRestitution@@YAKH@Z ?xenoIsRigidBodyALadder@@YAHH@Z ?xenoMakeCamera@@YAXHH@Z ?xenoMakeCharacterController@@YAXHMM@Z ?xenoMakeCharacterController@@YAXHMMM@Z ?xenoMakeCharacterController@@YAXHMMMM@Z ?xenoMakeCharacterController@@YAXHMMMMM@Z ?xenoMakeCharacterController@@YAXHMMMMMM@Z ?xenoMakeCharacterController@@YAXHMMMMMMM@Z ?xenoMakeRigidBodyDynamicBox@@YAXH@Z ?xenoMakeRigidBodyDynamicBox@@YAXHM@Z ?xenoMakeRigidBodyDynamicCapsule@@YAXH@Z ?xenoMakeRigidBodyDynamicCapsule@@YAXHM@Z ?xenoMakeRigidBodyDynamicCylinder@@YAXH@Z ?xenoMakeRigidBodyDynamicCylinder@@YAXHM@Z ?xenoMakeRigidBodyDynamicSphere@@YAXH@Z ?xenoMakeRigidBodyDynamicSphere@@YAXHM@Z ?xenoMakeRigidBodyStaticBox@@YAXH@Z ?xenoMakeRigidBodyStaticCapsule@@YAXH@Z ?xenoMakeRigidBodyStaticCylinder@@YAXH@Z ?xenoMakeRigidBodyStaticSphere@@YAXH@Z ?xenoMakeRigidBodyStaticTriangleMesh@@YAXH@Z ?xenoMakeVehicle@@YAXHH@Z ?xenoMoveCharacterControllerBackward@@YAXH@Z ?xenoMoveCharacterControllerForward@@YAXH@Z ?xenoMoveCharacterControllerLeft@@YAXH@Z ?xenoMoveCharacterControllerRight@@YAXH@Z ?xenoSetCharacterControllerPosition@@YAXHMMM@Z ?xenoSetCharacterControllerRotation@@YAXHM@Z ?xenoSetGravity@@YAXM@Z ?xenoSetGravity@@YAXMMM@Z ?xenoSetRigidBodyAllowedPenetrationDepth@@YAXHM@Z ?xenoSetRigidBodyAngularDamping@@YAXHM@Z ?xenoSetRigidBodyAngularVelocity@@YAXHMMM@Z ?xenoSetRigidBodyAsLadder@@YAXHH@Z ?xenoSetRigidBodyFriction@@YAXHM@Z ?xenoSetRigidBodyGravityFactor@@YAXHM@Z ?xenoSetRigidBodyLinearDamping@@YAXHM@Z ?xenoSetRigidBodyLinearVelocity@@YAXHMMM@Z ?xenoSetRigidBodyMass@@YAXHM@Z ?xenoSetRigidBodyMaxAngularVelocity@@YAXHM@Z ?xenoSetRigidBodyMaxLinearVelocity@@YAXHM@Z ?xenoSetRigidBodyPosition@@YAXHMMM@Z ?xenoSetRigidBodyRestitution@@YAXHM@Z ?xenoSetRigidBodyRotation@@YAXHMMM@Z ?xenoSetTimeStep@@YAXM@Z ?xenoStart@@YAXH@Z ?xenoStart@@YAXHM@Z ?xenoStart@@YAXHMH@Z ?xenoStart@@YAXXZ ?xenoUpdate@@YAXXZ ?xenoVehicleAccelerate@@YAXHM@Z ?xenoVehicleHandbrake@@YAXH@Z ?xenoVehicleReverse@@YAXH@Z ?xenoVehicleTurn@@YAXHM@Z When I try to use it in another C++ App like this #include <windows.h> class XenoPhysics { private: typedef void (*FunctionFunc)(void); typedef void (*FunctionFuncFloat)(float); typedef void (*FunctionFuncInt)(int); typedef void (*FunctionIntFloatFloatFloat)(int,float,float,float); HMODULE libInstance; public: void LoadLib() { this->libInstance = LoadLibrary(L"F:\\xenophysics.dll"); } void UnloadLib() { FreeLibrary(libInstance); } void xStart() { FunctionFunc curFunc; curFunc = (FunctionFunc)GetProcAddress(this->libInstance, "?xenoStart@@YAXXZ"); curFunc(); } void xEnd() { FunctionFunc curFunc; curFunc = (FunctionFunc)GetProcAddress(libInstance, "xenoEnd"); curFunc(); } void xUpdate() { FunctionFunc curFunc; curFunc = (FunctionFunc)GetProcAddress(libInstance, "xenoUpdate"); curFunc(); } void xMakeRigidBodyStaticBox(int objid) { FunctionFuncInt curFunc; curFunc = (FunctionFuncInt)GetProcAddress(libInstance, "xenoMakeRigidBodyStaticBox"); curFunc(objid); } void xMakeRigidBodyDynamicBox(int objid) { FunctionFuncInt curFunc; curFunc = (FunctionFuncInt)GetProcAddress(libInstance, "xenoMakeRigidBodyDynamicBox"); curFunc(objid); } void xSetRigidBodyPosition(int objid, float x, float y, float z) { FunctionIntFloatFloatFloat curFunc; curFunc = (FunctionIntFloatFloatFloat)GetProcAddress(libInstance, "xenoSetRigidBodyPosition"); curFunc(objid, x, y, z); } void xSetGravity(float grav) { FunctionFuncFloat curFunc; curFunc = (FunctionFuncFloat)GetProcAddress(libInstance, "xenoSetGravity"); curFunc(grav); } }; This is the "wrapper"(or whatever you would call it) class.. To call the functions I'm doing XenoPhysics * d = new XenoPhysics(); d->LoadLib(); d->xStart(); It then throws the following error at me(Note that it passes the LoadLib() without any errors) Unhandled exception at 0x50261bc9 in Xeno Test.exe: 0xC0000005: Access violation reading location 0x00000064. And yes; I've checked that the "curFunc" gets the address, not just a NULL pointer(atleast I think I've checked that).. Anyone who can help out? Edit: Forgot the C#.Net code, how stupid of me :3 Here is the C++ CLR DLL "wrapper" I tried to make: #include <windows.h> // The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the XENOWRAPPERWIN32_EXPORTS // symbol defined on the command line. this symbol should not be defined on any project // that uses this DLL. This way any other project whose source files include this file see // XENOWRAPPERWIN32_API functions as being imported from a DLL, whereas this DLL sees symbols // defined with this macro as being exported. #ifdef XENOWRAPPERWIN32_EXPORTS #define XENOWRAPPERWIN32_API __declspec(dllexport) #else #define XENOWRAPPERWIN32_API __declspec(dllimport) #endif typedef void (*FunctionFunc)(); typedef void (*FunctionFuncFloat)(float); typedef void (*FunctionFuncInt)(int); typedef void (*FunctionIntFloatFloatFloat)(int,float,float,float); // This class is exported from the xeno wrapper win32.dll class XENOWRAPPERWIN32_API Cxenowrapperwin32 { public: Cxenowrapperwin32(void); HINSTANCE libInstance; // FunctionFunc curFunc; // Library base functions void LoadLib() { libInstance = LoadLibrary(L"F:\\xenophysics.dll"); } void UnloadLib() { FreeLibrary(libInstance); } // Function calls to the xeno physics void xStart() { FunctionFunc curFunc; curFunc = (FunctionFunc)GetProcAddress(libInstance, "?xenoStart@@YAXXZ"); curFunc(); } void xEnd() { FunctionFunc curFunc; curFunc = (FunctionFunc)GetProcAddress(libInstance, "?xenoEnd@@YAXXZ"); curFunc(); } void xUpdate() { FunctionFunc curFunc; curFunc = (FunctionFunc)GetProcAddress(libInstance, "?xenoUpdate@@YAXXZ"); curFunc(); } void xMakeRigidBodyStaticBox(int objid) { FunctionFuncInt curFunc; curFunc = (FunctionFuncInt)GetProcAddress(libInstance, "?xenoMakeRigidBodyStaticBox@@YAXH@Z"); curFunc(objid); } void xMakeRigidBodyDynamicBox(int objid) { FunctionFuncInt curFunc; curFunc = (FunctionFuncInt)GetProcAddress(libInstance, "?xenoMakeRigidBodyDynamicBox@@YAXH@Z"); curFunc(objid); } void xSetRigidBodyPosition(int objid, float x, float y, float z) { FunctionIntFloatFloatFloat curFunc; curFunc = (FunctionIntFloatFloatFloat)GetProcAddress(libInstance, "?xenoSetRigidBodyPosition@@YAXHMMM@Z"); curFunc(objid, x, y, z); } void xSetGravity(float grav) { FunctionFuncFloat curFunc; curFunc = (FunctionFuncFloat)GetProcAddress(libInstance, "?xenoSetGravity@@YAXM@Z"); curFunc(grav); } }; extern XENOWRAPPERWIN32_API int nxenowrapperwin32; XENOWRAPPERWIN32_API int fnxenowrapperwin32(void); and here is how I use it in C#.Net class xeno { [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?LoadLib@Cxenowrapperwin32@@QAEXXZ")] public static extern void xLoadLib(); public void LoadLib() { xLoadLib(); } [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?UnloadLib@Cxenowrapperwin32@@QAEXXZ")] public static extern void xUnloadLib(); public void UnloadLib() { xUnloadLib(); } [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xStart@Cxenowrapperwin32@@QAEXXZ")] public static extern void xStart(); public void Start() { xStart(); } [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xUpdate@Cxenowrapperwin32@@QAEXXZ")] public static extern void xUpdate(); public void Update() { xUpdate(); } [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xEnd@Cxenowrapperwin32@@QAEXXZ")] public static extern void xEnd(); public void End() { xEnd(); } [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xMakeRigidBodyDynamicBox@Cxenowrapperwin32@@QAEXH@Z")] public static extern void xMakeRigidBodyDynamicBox(int objid); public void MakeRigidBodyDynamicBox(int id) { xMakeRigidBodyDynamicBox(id); } [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xMakeRigidBodyStaticBox@Cxenowrapperwin32@@QAEXH@Z")] public static extern void xMakeRigidBodyStaticBox(int objid); public void MakeRigidBodyStaticBox(int id) { xMakeRigidBodyStaticBox(id); } [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xSetGravity@Cxenowrapperwin32@@QAEXM@Z")] public static extern void xSetGravity(float grav); public void SetGravity(float g) { xSetGravity(g); } [DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xSetRigidBodyPosition@Cxenowrapperwin32@@QAEXHMMM@Z")] public static extern void xSetRigidBodyPosition(int obj, float x, float y, float z); public void SetRigidBodyPosition(int id, float q, float w, float e) { xSetRigidBodyPosition(id, q, w, e); } } And in the main C#.Net program I do xeno tx = new xeno(); tx.Start(); tx.SetGravity(-1); tx.MakeRigidBodyStaticBox(ground.Id); tx.MakeRigidBodyDynamicBox(cube.Id); tx.SetRigidBodyPosition(cube.Id, 0, 50, 0);

    Read the article

  • IRM Item Codes &ndash; what are they for?

    - by martin.abrahams
    A number of colleagues have been asking about IRM item codes recently – what are they for, when are they useful, how can you control them to meet some customer requirements? This is quite a big topic, but this article provides a few answers. An item code is part of the metadata of every sealed document – unless you define a custom metadata model. The item code is defined when a file is sealed, and usually defaults to a timestamp/filename combination. This time/name combo tends to make item codes unique for each new document, but actually item codes are not necessarily unique, as will become clear shortly. In most scenarios, item codes are not relevant to the evaluation of a user’s rights - the context name is the critical piece of metadata, as a user typically has a role that grants access to an entire classification of information regardless of item code. This is key to the simplicity and manageability of the Oracle IRM solution. Item codes are occasionally exposed to users in the UI, but most users probably never notice and never care. Nevertheless, here is one example of where you can see an item code – when you hover the mouse pointer over a sealed file. As you see, the item code for this freshly created file combines a timestamp with the file name. But what are item codes for? The first benefit of item codes is that they enable you to manage exceptions to the policy defined for a context. Thus, I might have access to all oracle – internal files - except for 2011_03_11 13:33:29 Board Minutes.sdocx. This simple mechanism enables Oracle IRM to provide file-by-file control where appropriate, whilst offering the scalability and manageability of classification-based control for the majority of users and content. You really don’t want to be managing each file individually, but never say never. Item codes can also be used for the opposite effect – to include a file in a user’s rights when their role would ordinarily deny access. So, you can assign a role that allows access only to specified item codes. For example, my role might say that I have access to precisely one file – the one shown above. So how are item codes set? In the vast majority of scenarios, item codes are set automatically as part of the sealing process. The sealing API uses the timestamp and filename as shown, and the user need not even realise that this has happened. This automatically creates item codes that are for all practical purposes unique - and that are also intelligible to users who might want to refer to them when viewing or assigning rights in the management UI. It is also possible for suitably authorised users and applications to set the item code manually or programmatically if required. Setting the item code manually using the IRM Desktop The manual process is a simple extension of the sealing task. An authorised user can select the Advanced… sealing option, and will see a dialog that offers the option to specify the item code. To see this option, the user’s role needs the Set Item Code right – you don’t want most users to give any thought at all to item codes, so by default the option is hidden. Setting the item code programmatically A more common scenario is that an application controls the item code programmatically. For example, a document management system that seals documents as part of a workflow might set the item code to match the document’s unique identifier in its repository. This offers the option to tie IRM rights evaluation directly to the security model defined in the document management system. Again, the sealing application needs to be authorised to Set Item Code. The Payslip Scenario To give a concrete example of how item codes might be used in a real world scenario, consider a Human Resources workflow such as a payslips. The goal might be to allow the HR team to have access to all payslips, but each employee to have access only to their own payslips. To enable this, you might have an IRM classification called Payslips. The HR team have a role in the normal way that allows access to all payslips. However, each employee would have an Item Reader role that only allows them to access files that have a particular item code – and that item code might match the employee’s payroll number. So, employee number 123123123 would have access to items with that code. This shows why item codes are not necessarily unique – you can deliberately set the same code on many files for ease of administration. The employees might have the right to unseal or print their payslip, so the solution acts as a secure delivery mechanism that allows payslips to be distributed via corporate email without any fear that they might be accessed by IT administrators, or forwarded accidentally to anyone other than the intended recipient. All that remains is to ensure that as each user’s payslip is sealed, it is assigned the correct item code – something that is easily managed by a simple IRM sealing application. Each month, an employee’s payslip is sealed with the same item code, so you do not need to keep amending the list of items that the user has access to – they have access to all documents that carry their employee code.

    Read the article

  • Object oriented wrapper around a dll

    - by Tom Davies
    So, I'm writing a C# managed wrapper around a native dll. The dll contains several hundred functions. In most cases, the first argument to each function is an opaque handle to a type internal to the dll. So, an obvious starting point for defining some classes in the wrapper would be to define classes corresponding to each of these opaque types, with each instance holding and managing the opaque handle (passed to its constructor) Things are a little awkward when dealing with callbacks from the dll. Naturally, the callback handlers in my wrapper have to be static, but the callbacks arguments invariable contain an opaque handle. In order to get from the static callback back to an object instance, I've created a static dictionary in each class, associating handles with class instances. In the constructor of each class, an entry is put into the dictionary, and this entry is then removed in the Destructors. When I receive a callback, I can then consult the dictionary to retrieve the class instance corresponding to the opaque reference. Are there any obvious flaws to this? Something that seems to be a problem is that the existence static dictionary means that the garbage collector will not act on my class instances that are otherwise unreachable. As they are never garbage collected, they never get removed from the dictionary, so the dictionary grows. It seems I might have to manually dispose of my objects, which is something absolutely would like to avoid. Can anyone suggest a good design that allows me to avoid having to do this?

    Read the article

  • Guide for http://www.ch-werner.de/javasqlite java wrapper library for SQlite?

    - by Tom Nielsen
    I'm working on a large computer science school project using java and SQlite. After finding out that the zentus.org wrapper errors on databases with ON DELETE and ON UPDATE clauses set, I have changed to the other wrapper found at http://www.ch-werner.de/javasqlite. However, I find the documentation lacking somewhat when trying to get an overview on how it works and how to use it, and the function descriptions are very very short, and you have to scan through every function and somewhat guess how they work and what they do. I wasn't able to find any guides on google on how to use it. My question: Does anyone know a link for a guide or tutorial for the ch-werner.de/javasqlite wrapper, or else can give me a basic code example, or give a quick overview of querying the database and the most used functions, and how to use them?

    Read the article

  • why primitive type will call first rather than wrapper classes?

    - by kandarp
    Hello EveryOne, public class A { public void test(Integer i) { System.out.println("In Wrapper Method"); } public void test(int i) { System.out.println("In primitive Method"); } public static void main(String args[]) { A a = new A(); a.test(5); } } When I will call test method from main and pass integer argument, then it will call the method which accept primitive type as argument. I just want to know that why it call primitive type method rather than the method who accepts wrapper class as argument? Is there any rule, which java follow to call methods? Thanks,

    Read the article

  • Simplest way to create a wrapper class around some strings for a WPF DataGrid?

    - by Joel
    I'm building a simple hex editor in C#, and I've decided to use each cell in a DataGrid to display a byte*. I know that DataGrid will take a list and display each object in the list as a row, and each of that object's properties as columns. I want to display rows of 16 bytes each, which will require a wrapper with 16 string properties. While doable, it's not the most elegant solution. Is there an easier way? I've already tried creating a wrapper around a public string array of size 16, but that doesn't seem to work. Thanks *The rational for this is that I can have spaces between each byte without having to strip them all out when I want to save my edited file. Also it seems like it'll be easier to label the rows and columns.

    Read the article

  • REST API wrapper - class design for 'lite' object responses

    - by sasfrog
    I am writing a class library to serve as a managed .NET wrapper over a REST API. I'm very new to OOP, and this task is an ideal opportunity for me to learn some OOP concepts in a real-life situation that makes sense to me. Some of the key resources/objects that the API returns are returned with different levels of detail depending on whether the request is for a single instance, a list, or part of a "search all resources" response. This is obviously a good design for the REST API itself, so that full objects aren't returned (thus increasing the size of the response and therefore the time taken to respond) unless they're needed. So, to be clear: .../car/1234.json returns the full Car object for 1234, all its properties like colour, make, model, year, engine_size, etc. Let's call this full. .../cars.json returns a list of Car objects, but only with a subset of the properties returned by .../car/1234.json. Let's call this lite. ...search.json returns, among other things, a list of car objects, but with minimal properties (only ID, make and model). Let's call this lite-lite. I want to know what the pros and cons of each of the following possible designs are, and whether there is a better design that I haven't covered: Create a Car class that models the lite-lite properties, and then have each of the more detailed responses inherit and extend this class. Create separate CarFull, CarLite and CarLiteLite classes corresponding to each of the responses. Create a single Car class that contains (nullable?) properties for the full response, and create constructors for each of the responses which populate it to the extent possible (and maybe include a property that returns the response type from which the instance was created). I expect among other things there will be use cases for consumers of the wrapper where they will want to iterate through lists of Cars, regardless of which response type they were created from, such that the three response types can contribute to the same list. Happy to be pointed to good resources on this sort of thing, and/or even told the name of the concept I'm describing so I can better target my research.

    Read the article

  • Using Lazy<T> and abstract wrapper class to lazy-load complex system parameters

    - by DigiMortal
    .NET Framework 4.0 introduced new class called Lazy<T> and I wrote blog post about it: .Net Framework 4.0: Using System.Lazy<T>. One thing is annoying for me – we have to keep lazy loaded value and its value loader as separate things. In this posting I will introduce you my Lazy<T> wrapper for complex to get system parameters that uses template method to keep lazy value loader in parameter class. Problem with original implementation Here’s the sample code that shows you how Lazy<T> is usually used. This is just sample code, don’t focus on the fact that this is dummy console application. class Program {     static void Main(string[] args)     {         var temperature = new Lazy<int>(LoadMinimalTemperature);           Console.WriteLine("Minimal room temperature: " + temperature.Value);         Console.ReadLine();     }       protected static int LoadMinimalTemperature()     {         var returnValue = 0;           // Do complex stuff here           return true;     } } The problem is that our class with many lazy loaded properties will grow messy if it has all value loading code inside it. This code may be complex for more than one parameter and in this case it is better to use separate class for this parameter. Defining base class for parameters As a first step I will define base class for all lazy-loaded parameters. This class is wrapper around Lazy<T> and it also offers one template method that parameter classes have to override to provide loaded data. public abstract class LazyParameter<T> {     private Lazy<T> _lazyParam;       public LazyParameter()     {         _lazyParam = new Lazy<T>(Load);     }       protected abstract T Load();       public T Value     {         get { return _lazyParam.Value; }     } } It is also possible to extend Lazy<T> but I don’t prefer to do it as Lazy<T> has six constructors we have to take care of. Also I don’t like to expose Lazy<T> public interface to users of my parameter classes. Creating parameter class Now it’s time to create our first parameter class. Notice how few stuff we have in this class besides overridden Load() method. public class MinimalRoomTemperature : LazyParameter<int> {     protected override int Load()     {         var returnValue = 0;           // Do complex stuff here           return returnValue;     } } Using parameter class is simple. Here’s my test code. class Program {     static void Main(string[] args)     {         var parameter = new MinimalRoomTemperature();         Console.WriteLine("Minimal room temperature: " + parameter.Value);         Console.ReadLine();     } } Conclusion Lazy<T> is useful class that you usually don’t want to use outside from API-s. I like this class but I don’t like when people are using this class directly in application code. In this posting I showed you how to use Lazy<T> with wrapper class to get complex parameter loading code out from classes that use this parameter. We ended up with generic base class for parameters that you can also use as base for other similar classes (you have to find better name to base class in this case).

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >