State of TwinCAT events is not correct in the HMI and Visual Studio Logged Events - twincat

We use the TwinCAT 3 Event Logger to track events in our machine. The events are shown to the user with the Event grid control.
Alarms which are raised shows up correctly in the event grid. Every so often it happens that an alarm is cleared, but it never updates in the grid control as cleared. Also when we check the alarm in Visual Studio with the Logged Events window, it doesn't have a cleared date. However, when we check the state of the FB_TcAlarm it has a cleared date or the eConfirmationState is set as NotRequired which means the alarm is currently not in the raised state.
The weird thing is that this doesn't always happen--most of the time the alarms work correctly. Only in rare cases they don't work. Also it is not always the same alarms which malfunction.
Anyone else if suffering from this? Or any idea how to solve/reproduce this?

I have kind of the same problem, but for me it happens when I change something in the code (I have a dynamic array of TcCom objects and FB_Alarms get their own index and register to those TcCom objects with their own name and message) and if I change the name (which is used for doublechecking index) or reset to origin, the old indexes are reset and the old alarms cannot be confirmed away since the original recipient is no longer there. At this point I have to clear logged events through XAE to PLC, stop HMI and delete 2 files in the server.
I know this is not a complete answer, but it helps to know that the HMI has its own eventLogger instance with its own record, PLC has it's own too, and one possible reason for unresponsive alarms is that the recipient FB_TcAlarm has been changed.

The problem seems to have disappeared after we updated to HMI v1.12 and TwinCAT version 4024.10 I believe.

Related

TFS Suspend State Tracking

I would like our team, to be able, to communicate to others easily, if they have suspended their work with a given reason.
So I would like to have the WIT's with an additional state named "suspended" and an given comment.
What we now would like to achieve, is that the newly added suspended state is set, when we press the suspend work button.
How to add an additional state is clearly documented on the msdn, but is there any possible way, to achieve the above mentioned behaviour, where we do not have to switch to all the associated WIT's and set the state manually?
Your requirement can't be achieved by default. You would need to customize your own add-in in VS.

Check visibility or status change of a window

I have to enumerate all process running on my machine and notify if some changement will happen (for example: change of visibility of windows, open a new window, close a window).
To enumerate all processes I can use this function provided by MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682623(v=vs.85).aspxI thought that I need to save a list of running processes and check (how without polling?) if it changes. Can I do it without saving current running processes?
For the visibility changes here https://msdn.microsoft.com/it-it/library/windows/desktop/ms646274(v=vs.85).aspx I found that VM_ACTIVATE message is sent to both windows. How can I catch it? Can I do it in another way?
For whom is interested in this topic, I found that to check if a window is created or destroyed I've to use SetWinEventHook(), like in the example of its MSDN page. I simply check if event value is EVENT_OBJECT_CREATE or EVENT_OBJECT_DESTROY. For other events, check the event constants list.

In a Visual Studio Extension, how to detect when the debugger Continues

I need my Visual Studio extension to react to debugging events. I've registered a IDebugEventCallback2 and I'm receiving events, but all I get for each event is an opaque IDebugEvent2 and a Guid, many of which are not only undocumented but don't appear anywhere on the web (or in my registry).
My specific requirement at the moment is to know when the process is Continued - ie. the user has hit Continue, Run to cursor, etc. What Guid should I be looking for?
Or is there some other event family that I should be subscribing to?
(More generally, is there some way I'm missing to find out about the events that are delivered to my IDebugEventCallback2::Event callback, when many of them don't appear in MSDN or anywhere else? Thanks!)
There is no easy way to do this. Actions such as Continue and Run to cursor are abstractions implemented by Visual Studio and do not correspond to any unique event(s) with respect to the debug engine. The debug engine event reporting interface IDebugEventCallback2 will enable you to get notified only on fine-grained events such as when creating a breakpoint or reaching a breakpoint.
While Visual Studio enables you to perform actions such as Continue and Run to cursor programmatically, it does not provide a direct way to get notified when they are taken.
You can use EnvDTE.DebuggerEvents.OnXxx events to get notified when something is about to happen. In particular, the OnEnterBreakMode event enables you to intercept a breakpoint hit and possibly take an action. You can also inspect all the details of the reached breakpoint(s) using the current EnvDTE.Debugger inside the event handler.
Now with some effort, you can use these constructs to implement events that correspond to all Visual Studio debugging actions including Continue and Run to cursor accurately. If you require additional events not provided by EnvDTE.DebuggerEvents (such as when a breakpoint is inserted), you have no choice but use IDebugEventCallback2.Event. In this case if you have specific events in mind, please mention them explicitly and I might be able to tell you the corresponding IDebugEventCallback2.Event GUIDs.
You probably got off on the wrong foot here, the IDebugXxx interfaces were really intended to create your own debugging engine. Still useful perhaps to see what is going on in the existing engine, you are suppose to use QueryInterface() to discover the specific interface that matches the event. Like IDebugEngineCreateEvent2, IDebugProcessCreateEvent2, IDebugProcessDestroyEvent2, etcetera. There are a bunch of them, they are listed in the VSSDK\VisualStudioIntegration\Common\Inc\msdbg.h header and include their IID.
Best thing to do is peek at this sample, it shows how to crack the event notification into the specific interfaces. The AD7Events.cs source file shows the wrappers. Do keep in mind that this sample was made to show how to create an engine, not how to use the one already built into VS.
But yes, you are not going to get a "continue debug" event out of this. A debugging engine does not need that event since it is already responsible for taking care of that by itself. It already knows when it calls IDebugProgram3::Continue().
Surely what you are looking for is IVsDebugger.AdviseDebuggerEvents(). That's the one that tells you what the built-in debugger is doing. You need to pass an object of a class that implements IVsDebuggerEvents, your OnModeChanged() method will be called with a DBGMODE notification. I don't see a lot of fantastic examples that demonstrate usage, this web page might be helpful.

CMFCToolbar ReplaceButton() causes button to disappear

Using Visual Studio 2010 and working with an MFC SDI Application.
I have a CMFCToolbar object owned by the Main Frame.
When the document in this application is created, the MainFrame calls a function to replace one of the buttons in the CMFCToolbar object with a CMFCToolbarMenuButton. The contents of the menu button are populated with information from the document. The menu creation always works. The call to ReplaceButton always succeeds. But there's a visual symptom of the call that I haven't yet figured out.
Any time ReplaceButton is called, the button disappears. Not only is it not drawn, it's not clickable. It's temporarily gone. I assume this is because there's a dangling reference to the old button, which I have just destroyed with the call to ReplaceButton.
I've tried calling Invalidate(), RecalcLayout() to trigger a re-draw, but neither has worked yet. The only reliable method I have for getting the button to show up is re-sizing the application window manually or by un-docking/re-docking the toolbar. I assume there's some kind of lower-level refresh that occurs in these situations, but I don't know how to trigger it manually.
Is there a way to make sure my button is drawn immediately?
Edit: code sample
Count = m_Doc->...->GetCount();
for (Index = 0; Index < Count; ++Index)
{
Caption.Format(L"%s", m_Doc->...->GetName());
m_pLayerMenu->AppendMenu(MF_ENABLED | MF_STRING, LAYER_DROP_SEED+Index, Caption.GetData());
}
m_wndBrushBar.ReplaceButton(ID_BRUSH_TERRAIN,
CMFCToolBarMenuButton(ID_BRUSH_TERRAIN, *m_pLayerMenu, GetCmdMgr()->GetCmdImage(ID_BRUSH_TERRAIN)));
Update:
Calling m_wndBrushBar.AdjustLayout() seems to stabilize the visual behavior of these CMFCToolbar buttons. So that's a partial solution.
Partial because of the following:
It's hard to tell what the real visual behavior is. It turns out that all visual settings/states are stored in the Registry with these MFC objects, and it can hold onto states of dynamically created objects that really alter the startup behavior of the app.
I've gone in to delete the registry values under
Current User -> "Local App-Wizard Generated Applications" -> [My App Name].
Done this a number of times, just to find out what the real behavior of my app is. Feel like I'm missing some fundamental knowledge with the current version of MFC. Lots of bugs arising from the registry deal.
Is there a way to prevent registry settings for certain objects, or to shut off this behavior altogether? Otherwise, I guess my shutdown process will have to be a LOT more thorough with resetting all the visual elements. Registry values seem to ignore, override, or bypass my startup code. I can code how I want an object to look at startup, but if there are values in the registry, it does no good.
You've discovered a sometimes annoying aspect for the CMFC code. That is, the concept of a Workspace. The Workspace manages the concept of the application state. I, too, have had problems like the one you describe. But, you have the flexibility to manage how those objects are recreated by overriding the LoadState () and SaveState () methods.

Calendar control showing long DayLength suddenly

I have a Calendar control on a VB6 form which on one machine is suddenly showing long day names instead of the single initials of the days like it is designed to.
eg. Monday instead of M
At design time this is set with the DayLength property which I have set to Short, but for some reason on one machine it is showing as though it is set to Long.
What is the cause of this? Is there a registry setting or something else that would be doing this?
Unregister then register the calendar control.
This may be achieved by repairing or reinstalling the product.

Resources