|
This is for CallInIt
void Ball::classInit( RTI::RTIambassador* rtiAmb )<br />
{<br />
ObjectRoot::ms_rtiAmb = rtiAmb;<br />
ObjectRoot::ms_classIdStr = ms_ballIdStr;<br />
<br />
if ( ms_rtiAmb )
{<br />
ms_classId = ms_rtiAmb->getObjectClassHandle( ms_classIdStr );<br />
ms_ballId = ms_rtiAmb->getObjectClassHandle( ms_ballIdStr );<br />
ms_ballLocationXId = ms_rtiAmb->getAttributeHandle( ms_ballLocationXIdStr, ms_ballId );<br />
ms_ballLocationYId = ms_rtiAmb->getAttributeHandle( ms_ballLocationYIdStr, ms_ballId );<br />
ms_ballVelocityXId = ms_rtiAmb->getAttributeHandle( ms_ballVelocityXIdStr, ms_ballId );<br />
ms_ballVelocityYId = ms_rtiAmb->getAttributeHandle( ms_ballVelocityYIdStr, ms_ballId );<br />
ms_clockTickId = ms_rtiAmb->getInteractionClassHandle( ms_clockTickIdStr );<br />
ms_clockTickNumId = ms_rtiAmb->getParameterHandle( ms_clockTickNumIdStr, ms_clockTickId );<br />
ms_clockTickTimeId = ms_rtiAmb->getParameterHandle( ms_clockTickTimeIdStr, ms_clockTickId );<br />
ms_clockTickIntervalId = ms_rtiAmb->getParameterHandle( ms_clockTickIntervalIdStr, ms_clockTickId );<br />
}<br />
}
This is for InIt
void RoundTable::Init( RTI::RTIambassador* rtiAmb )<br />
{<br />
ms_rtiAmb = rtiAmb;<br />
<br />
if ( ms_rtiAmb )<br />
{<br />
<br />
try<br />
{<br />
ms_tableTypeId = ms_rtiAmb->getObjectClassHandle( ms_tableTypeStr );<br />
ms_radiusTypeId = ms_rtiAmb->getAttributeHandle( ms_radiusTypeStr,<br />
ms_tableTypeId); <br />
ms_coefElastTypeId = ms_rtiAmb->getAttributeHandle( ms_coefElastTypeStr,<br />
ms_tableTypeId);<br />
ms_coefFrictionTypeId = ms_rtiAmb->getAttributeHandle( ms_coefFrictionTypeStr,<br />
ms_tableTypeId);<br />
}<br />
catch(RTI::FederateNotExecutionMember e)<br />
{<br />
cerr<<"RoundTable Exception: "<<__LINE__<<endl; <br />
}<br />
}<br />
}
|
|
|
|
|
Is there any sites or books that I can use to study the RTI syntax and how federates get published when another federate subscribes for it. And also the use of Id's in variables. Im a beginner in this and in need of some serious help. It would be great if you can point me to some books or sites.
Thanks,
Jay
|
|
|
|
|
Sadly, no. RTI-NG is a closed-source proprietary library that you have to purchase licenses to use. Since its purpose is limited to modelling and simulation for government contracts, there isn't much wide-spread knowledge on it.
Some of the companies in the industry offer weeklong courses to discuss working with the varying versions of RTI. You might see if GT will pay for you to attend one.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
RTI is vender specific. Different venders may have different implementations. The contraint to RTI is basically HLA (and IEEE 1516) spec, which is fairly loose. I am not aware of any books about RTI. There are only training materials, which again are verder specific and very top level.
I think what you lack is programming fundamentals and a good understanding of C++ language. Take a C++ book and study it seriously. This preparation effort will be paid back.
Best,
Jun
|
|
|
|
|
Jay,
Given some of your other questions recently, you might do better to start by getting a stong working understanding of C++.
earl
|
|
|
|
|
Hi all,
My app needs to destroy a shortcut on the desktop (located in "AllUsers", running on Windows XP). Since the users are not administrators, I use the following code to connect with a dedicated admin account. The (existing) link to delete is "bcFile".
This code works fine with an administrator account and return with no error for normal users. In the later, the shortcut diseapear from the destop only to reappear when the end user press F5. I personnaly guess for a problem in the quotation marks from wCommand or wParams.
PROCESS_INFORMATION pi;
AnsiString sCommand = "C:\\windows\\system32\\cmd.exe";
int iBuffSize = sCommand.WideCharBufSize();
wchar_t* wCommand = new wchar_t[iBuffSize];
wCommand[0] = 0;
sCommand.WideChar(wCommand, iBuffSize);
AnsiString sParams = " del \"/C \"" + bcFile + "\"\" ";
wchar_t wParams[MAX_PATH + 1];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sParams.c_str(), -1, wParams, MAX_PATH);
AnsiString sUsername = "masteraccount";
AnsiString sDomain = "production";
AnsiString sPassword = "234l2k3j4";
if (CreateProcessWithLogonW(
static_cast<const wchar_t*>(sUsername.data()),
static_cast<const wchar_t*>(sDomain.data()),
static_cast<const wchar_t*>(sPassword.data()),
LOGON_NETCREDENTIALS_ONLY, wCommand,
wParams, 0, NULL, NULL, NULL, &pi) != 0) {
// Notify the shell for delete operation.
SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, bcFile.c_str(), NULL);
}
else {
CustomErrorHandler(ERR_ABORT, ERR_DEL_SHORTCUT);
}
Any help on this or another way to do the shortcut delete will be appreciated.
-- modified at 8:34 Tuesday 11th July, 2006
|
|
|
|
|
Hi,
Due to the tremedeous replies, I finally worked it out myself.
So forget about the CreateProcess stuff.
I now use "CreateThread", in which I call "LogonUser".
Works fine. Simplier. No dependencies to "cmd.exe".
|
|
|
|
|
I have an SDI application. This SDI application has a Splitter control, which has Pane controls and the pane controls themselves have other child controls. So, there is a hierarchy of controls. Now, If I have the handle of any child control, I want to get the Handle of the SDI application window. Is there any way to achieve this?
GetParent() may work, but I would certainly not know how many GetParent()s I am supposed to call. For Example, if I have the HWND of the PaneControl, I would have to call GetParent() twice. One for the Splitter control and the other for the application Window. Similarly, if I have the handle of the Splitter control, I would have to call GetParent() only once. This is the why I think GetParent() is not such a good idea. Any other options?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
use AfxGetMainWnd type cast the return window to your derived FrameWnd Class
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
Thanks. What if I am not using MFC and using the Win32 API?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
Try AfxGetMainWnd()
From MSDN:
If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call.
Regards
Abhishake
|
|
|
|
|
Would this suffice:-
CWnd* AFXAPI AfxGetMainWnd( );
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
Hakuna-Matada wrote: This is the why I think GetParent() is not such a good idea. Any other options?
thats right GetParent is good Idea
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
hello
I am trying to make a list control , so that it will display both name and
number when i enter them.
1) how do i delete an item from the list control
ie
void CSpeedDial::OnSpeedDel()
{
//
}
2)how do i move an item up or down in the list contol using "up buttom" and
"down buttom" i have created
ie
void CSpeedDial::OnSpeedUp()
{
}
and
void CSpeedDial::OnSpeedDown()
{
}
3)how do i make the "add buttom" disable when i have 8 items in the list
control.
this is what I have done so far:
BOOL CSpeedDial::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
m_speedList.GetClientRect(&rect);
m_speedList.InsertColumn(0,_T("Name"),LVCFMT_LEFT,rect.Width()/2,0);
m_speedList.InsertColumn(1,_T("Number"),LVCFMT_LEFT,rect.Width()/2,0);
m_speedList.SetImageList(&imList, LVSIL_SMALL);
for (int i=0;i< m_speedArray.GetSize();i++)
{
m_speedList.InsertItem(i,m_speedArray.GetAt(i));
}
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSpeedDial::OnSpeedAdd()
{
// TODO: Add your control notification handler code here
CString AliasName,AliasNumber;
m_speedName.GetWindowText(AliasName);
m_speedNumber.GetWindowText(AliasNumber);
AliasName.TrimRight();
AliasName.TrimLeft();
AliasNumber.TrimLeft();
AliasNumber.TrimRight();
if(AliasName.FindOneOf("=|")>=0) return;
int nIndex = m_speedList.InsertItem(m_speedList.GetItemCount(),AliasName);
m_speedList.SetItemText(nIndex,1,AliasNumber);
m_speedName.SetWindowText(_T(""));
m_speedNumber.SetWindowText(_T(""));
}
thanks for you help
|
|
|
|
|
You can decide it, on PretraslateMessage, or WM_KEYDOWN message.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
jokefake wrote: 1) how do i delete an item from the list control
By using the DeleteItem() method.
jokefake wrote: 2)how do i move an item up or down in the list contol using "up buttom" and
"down buttom" i have created
By deleting it and inserting it into the correct location.
jokefake wrote: 3)how do i make the "add buttom" disable when i have 8 items in the list
control.
By using the EnableWindow() method.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i did sth like this but it is not working
void CSpeedDial::OnSpeedDelete()
{
POSITION pos = m_speedList.GetFirstSelectedItemPosition();
if(pos == NULL) return;
int index = m_speedList.GetNextSelectedItem(pos);
if(index<0 || index>m_speedList.GetItemCount()||
m_speedList.GetItemCount()!= m_speedArray.GetSize())
return;
m_speedList.DeleteItem(index);
m_speedArray.RemoveAt(index);
// TODO: Add your control notification handler code here
}
|
|
|
|
|
jokefake wrote: i did sth like this but it is not working
So what's not working with it? You've got a lot of code there that needs to be narrowed down to just a single statement or two. Set breakpoints. Use the debugger. Step into the code to see what is going on.
The first thing to try is this:
void CSpeedDial::OnSpeedDelete()
{
m_speedList.DeleteItem(0);
} If this works, then you know what the problem is not.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Why don't you share with others what the resolution was?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i just removed some of the lines from the code
void CSpeedDial::OnSpeedDelete()
{
POSITION pos = m_speedList.GetFirstSelectedItemPosition();
int index = m_speedList.GetNextSelectedItem(pos);
m_speedList.DeleteItem(index);
// TODO: Add your control notification handler code here
}
but how can i move an item up and down in the list
i am a beginner
|
|
|
|
|
jokefake wrote:
i just removed some of the lines from the code
void CSpeedDial::OnSpeedDelete()
{
POSITION pos = m_speedList.GetFirstSelectedItemPosition();
int index = m_speedList.GetNextSelectedItem(pos);
m_speedList.DeleteItem(index);
// TODO: Add your control notification handler code here
}
Which can be shortened to:
void CSpeedDial::OnSpeedDelete()
{
int index = m_speedList.GetNextItem(-1, LVIS_SELECTED);
if (index != -1)
m_speedList.DeleteItem(index);
} jokefake wrote: but how can i move an item up and down in the list
By deleting it and inserting it into the correct location.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks, that code is really short and simple.
I tried moving a selected item up in the list control, but it is not working.
what may wrong with the code
void CTestingDlg::OnUp()
{
int index = m_cListCtrl.GetNextItem(-1, LVIS_SELECTED);
m_cListCtrl.InsertItem(index -1, m_cListCtrl.GetItemText(index, index));
m_cListCtrl.DeleteItem(index +1);
// TODO: Add your control notification handler code here
}
|
|
|
|
|
Delete first, then insert.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
deleting it first, deletes the row as i click on the buttom
i extracted my code from here.
BOOL CListCtrlEx::MoveRow(int from, int to)
{
//Can't move to the same place, or from or to a negative index
if(from == to || from < 0 || to < 0)
return FALSE;
//First Copy the row to the new location
if(CopyRow(from, to))
{
//If we have just inserted a row before
//this one in the list, we need to increment
//our index.
if(from > to)
DeleteItem(from + 1);
else
DeleteItem(from);
return TRUE;
}
else
return FALSE;
}
BOOL CListCtrlEx::CopyRow(int from, int to)
{
//Can't move to the same place, or from or to a negative index
if(from == to || from < 0 || to < 0)
return FALSE;
//Copy the row to the new index
InsertItem(to, GetItemText(from, 0));
//If row has been inserted before original
//increment the original
if(from > to)
from++;
//Loop through subitems
for(int i = 1; i < GetColumnCount(); i++)
{
SetItemText(to, i, GetItemText(from, i));
}
return TRUE;
}
|
|
|
|
|