|
You might also want to be careful that if you did store the address, you don't try to use it after the class is destroyed.
|
|
|
|
|
I have got a small problem with ActiveX control..When i place it inside activeX container, initially it sticks to the rectangle (previously in which ellipse is drawn by default). When i resize the drawing in onDraw(), it clips the outer parts and initially it displays the part in the default rectangle area whateva can come inside it. I need a tip to initialize the rectangular area with my own bounds .Please do reply, i am helpless in my final year project without getting to solve this problem , thanks.
|
|
|
|
|
Hi everyone outthere,
I have a regluar TTL Signal. Like this one:
Now i need to detect the distance between these two points:
This and This
\/ \/
----- ----- -----
| | | | | |
| | | | | |
--------| |---| |---| |---
Hope you understand what i mean ^^.
Here is a link to a drawing
http://www.cofan.co.kr/image/other/et05.gif
just look at the signal not at all the Data which stands there.
RedDragon2kx
|
|
|
|
|
not at all...
coy your scheme into a <pre></pre> block to let us see the spaces...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I need to get the time between
This This
\/ \/
|----| |----| |----|
| | | | | |
| | | | | |
-----| |----| |----| |----
Points. I hope it works now ^^
|
|
|
|
|
What are you trying to accomplish here? Is this a software project, or hardware? Do you have an input card that you're monitoring, or is this sampled data in a file?
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
It's a hardware device that I'm monitoring. It's a TTL Signal, I believe it's only produced by Transistors but I'm not sure. Sorry for my bad description.
|
|
|
|
|
Okay, that's clear. Now, what are you using to monitor it? Do you have a digital input card or analog? Are you digitizing samples into a file, or simply ones and zeroes? In either case the method is similar, though an analog sampling device takes a bit more work to decide when the signal state has changed.
Method 1:
Sample the signal at a fixed interval of time. How often depends on the accuracy of measurement required. Initialize a counter on the first falling edge, then increment it until the next falling edge is detected. Multiply the count by the time between samples.
Method 2:
As before, sample at regular intervals, depending on the accuracy needed. At the first falling edge, read the system clock and save the value. At the second, read the clock again, then calculate the difference between the two values.
Since it's not really clear yet what you are looking for, one efficient way to detect a state change - assuming you're looking at a stream of digital inputs, not digitized analog - is to XOR the current value with the previous value. If the result is true, and the current value is 0, you have just found a falling edge. If the result is true and the current value is 1, you've detected a rising edge. Anytime the result of the XOR is false, the values match and no state change has occurred.
Both methods will be somewhat unreliable under Windows, as you can't guarantee that some samples won't be missed or delayed because of other tasks grabbing the CPU just before a new sample is scheduled. This is an application where a hardware solution is easier and better to use. A simple gate circuit to enable or disable a fixed, accurate clock signal connected to a counter will do the trick. The only trouble with a hardware solution is that, while the actual measurement circuit is trivial, the interface required to make it readable by a PC involves a lot of overhead. Why not buy a device made for the purpose? Dataq (www.dataq.com[^]) makes a line of inexpensive modules which connect to a serial port and come with software to use them for various measurements of this sort.
Good luck!
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
First i'd like to say thank you for the help. I get the TTL Signal via the Line In Port in my Computer and the data is is processed with an FFT Algorithmus that i found on the internet and i wanted to use the points the FFT returns, is it possible ?
|
|
|
|
|
Interesting. How in the world did you find a way to access the LineIn on a sound card? I didn't know that it was possible. Or is this some kind of analog to digital converter card you have? There is no such thing as a Line In "port" on a PC, but sound cards have audio input jacks by that name.
If you are accessing data that can be FFT'd you should be looking at digitized analog voltages. If you want to work with the raw data, you could scan the data for peaks followed by minimums, then pick an arbitrary point halfway between them to call the transition point. The number of samples between high-to-low transitions divided by the sample rate (#samples / samples per second) will yield the time between transitions.
Simpler, though, if you have the FFT data available, is to simply locate the peak value and determine its frequency. Since this is frequency domain data, the peak represents the fundamental frequency of the input signal. That corresponds exactly with the period you're trying to determine. Each data point in the FFT output array contains the magnitude of the input signal due to a frequency that is a multiple or submultiple of the sample rate. Locating the peak will be easy - in a square wave such as you've illustrated, the fundamental component is half the peak value, and since it contains only odd harmonics there will be much smaller peaks at 3f0, 5f0, 7f0, etc. The inverse of the frequency of the largest value in the array is the period of the signal.
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
Thanks for your help You are right im using the Line In Jack at my Soundcard not the port (sorry, but I'm from Germany). I think i gonna maybe write an article about this Topic. ^^
|
|
|
|
|
RedDragon2k wrote:
I think i gonna maybe write an article about this Topic.
Cool!
I'd love to know how to access the soundcard hardware. It's a handy device for its intended purpose, but it would be much more useful if we could easily use its A/D and D/A converters for other uses.
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
Hi all
I want to use coInitializeSecurity() in my program
i included objbase.h and define win32_DCom but
i got an error Undeclared Identifier .the same problem with coCreateInstanceEx() . but there isnot any error with coCreateInstance().
thank you
|
|
|
|
|
Hi,my class definement is as follows:
class A
{
public:
A(){cout<<"A::A()"<
|
|
|
|
|
i'm not sure of the output, but the first thing i see is that you derive A and its destructor (A::~A() ) is not declared as virtual ...
i think so the output is:
A::A()
A::A()
B::B()
A::~A()
A::~A()
is is wrong ? (i did not compile to test, so i may have written an error, but that was the game, wasn't it ? )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
bobi_zcl wrote:
what is the output result?why?
Why don't you step through it yourself and find out? Note that the code in main() won't work on VC7.x, the declarations of a and b will be treated as function prototypes, not variable declarations. If you use 7.x you'll need to change it to:
A a = A();
A b = B();
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
I have problem with running my application on PCs with pentium IV processors. On AMD processors it runs without problems. When I analyzed the problem, I have found that memcpy function probably does not behave correct. Is this some compiler bug (I am using MS Visual .NET 2001) or something like memory aligment fault? On pentium IV application crashes with "memory protection fault". If I well understand MS article "Windows data alignment" memory aligment cannot cause application crash on pentium IV, it can only cause worse performance, so it is not probably this kind of problem.
|
|
|
|
|
Is your application multi-threaded? If so it could be a race condition.
Most Pentium 4 processors use HyperThreading (HT) technology. These Pentium 4 processors are multi-cored processors. They will behave differently than on a single core processor like the AMD chip range.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
you are right, my application is multi-threaded. I use one thread for loading, this thread creates some data, which then the parent thread use. So if I load data in same thread as I will use them, then I solve the problem? Or is there some simple solution to conserve multi-threading and avoid this problem, some way to disable hyperthreading?
|
|
|
|
|
It would seem that you have a bug in your program that you need to fix. It is pure luck that you do not see it on AMD processors. Altering the environment may mask the problem on the machines you are able to test on though this is not a guaranteed solution in general.
From your description of what you are doing here are a few tips:
Your suggestion of loading the data into the thread that you are using it in is a good one. One thread accessing the data is always easiest.
When accessing data across threads there is need to ensure that only one thread can use the data at any one time (serialize data access). One way to achieve this is to use critical sections.
Do not allocate memory in one thread and clean it up in another. It is far easier to manage memory allocation / deallocation in the same thread.
If all else fails, there are many articles out there about multi-threaded applications programming. You will probably find a few here at CP.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I am using GD+ in my ActiveX Control. It Works. But TSTCON32.exe not removed from memory.It is still running even after i closed testContainer(TSTCON32) application. Please look at this simple code and tell me problem.
Here is the Code.It simply initialize in InitInstance and Shutdowns in ExitInstance.
AfxStd.h
/////
#if !defined(AFX_STDAFX_H__C2F7B03D_540F_42F2_B794_2FEF9ED71973__INCLUDED_)
#define AFX_STDAFX_H__C2F7B03D_540F_42F2_B794_2FEF9ED71973__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxctl.h> // MFC support for ActiveX Controls
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Comon Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment(lib, "gdiplus.lib")
// Delete the two includes below if you do not wish to use the MFC
// database classes
#include <afxdb.h> // MFC database classes
#include <afxdao.h> // MFC DAO database classes
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__C2F7B03D_540F_42F2
TestApp.H - Application class header file.
#if !defined(AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED_)
#define AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// dfdsf.h : main header file for DFDSF.DLL
#if !defined( __AFXCTL_H__ )
#error include 'afxctl.h' before including this file
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CDfdsfApp : See dfdsf.cpp for implementation.
class CDfdsfApp : public COleControlModule
{
private:
GdiplusStartupInput gdiplusStartupInput; // GDI+ Object
ULONG_PTR gdiplusToken; // GDI+ Pointer
public:
BOOL InitInstance();
int ExitInstance();
};
extern const GUID CDECL _tlid;
extern const WORD _wVerMajor;
extern const WORD _wVerMinor;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED)
////////////////////////////
TestApp.Cpp - Applications cpp file
#if !defined(AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED_)
#define AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// dfdsf.h : main header file for DFDSF.DLL
#if !defined( __AFXCTL_H__ )
#error include 'afxctl.h' before including this file
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CDfdsfApp : See dfdsf.cpp for implementation.
class CDfdsfApp : public COleControlModule
{
private:
GdiplusStartupInput gdiplusStartupInput; // GDI+ Object
ULONG_PTR gdiplusToken; // GDI+ Pointer
public:
BOOL InitInstance();
int ExitInstance();
};
extern const GUID CDECL _tlid;
extern const WORD _wVerMajor;
extern const WORD _wVerMinor;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DFDSF_H__B2B70A2B_F958_46E4_B51D_CE3FE9A11D59__INCLUDED)
These are only files which has code related to GDI+. I used ActiveControl Wizard. And I added the code to StartUp GDI+ nad Shutdown GDI+. That's it. I did not write any other code.
|
|
|
|
|
im now doing digit recognition,but cant run at all,problems is exist..
i cant solve for the header file too,even look through example in textbook,hv same problem..
i understand the counting of MLP,but when apply into my coding,hv problem..how???
thanks for reply..
|
|
|
|
|
hi all,
suppose that I have a File Called "abc.mdf" in C Drive ..Now I want to copy it to another directry in "D" Drive ..
So How do I do it using C++?
Thanks in advance..
|
|
|
|
|
You can call Win32 API
CopyFile(
"C:\\abc.mdf", // name of an existing file
"D:\\abc.mdf", // name of new file
FALSE // operation if file exists
);
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
CopyFile() or SHFileOperation() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|