Applies To:
  • CitectSCADA 1.xx 2.xx 3.xx 4.xx 5.xx 6.00 6.10
  • CitectHMI 1.xx 2.xx 3.xx 4.xx 5.xx 6.00 6.10  

Summary:
Question: I would like to automate the compilation procedure so that when the compilation is completed I can automatically install and startup the system. It is possible to do this? 

Solution:
When the Citect compiler finishes its compilation it will broadcast a windows message to all windows applications that the compilation has been completed. This is how CtEdit detects when the compilation has completed and changes the status of your database from UNCOMPILED to COMPILED. You may also detect this message for you own use.

To detect the compilation completion messages you need to use the Windows SDK function RegisterWindowMessage() to register the messages "WM_COMPILED" and "WM_UNCOMPILED". Then just wait until you see these messages. You will need to be and experienced Windows programmer and use a C, C++ or other compiler with the Windows SDK to do this operation.

UINT hMsg;

// at startup register the new message
hMsg = RegisterWindowMessage("WM_COMPILED");
...

// In your windows procedure
long PASCAL
MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   if (message == hMsg)
   {
      // database is compiled
   }
}

This can also be done under the Microsoft .NET Framework. The following example is in C#.
using System.Windows.Forms;
using System.Runtime.InteropServices;

// Inside your main program class
[STAThread]
static void Main()
{
CompilerMessageFilter filter = new CompilerMessageFilter();
Application.AddMessageFilter(filter);
...
}

// Custom message filter for detecting CitectSCADA compiler messages
public class CompilerMessageFilter : IMessageFilter
{
private uint wm_compiled = 0;
private uint wm_uncompiled = 0;

public CompilerMessageFilter()
{
wm_compiled = RegisterWindowMessage("WM_COMPILED");
wm_uncompiled = RegisterWindowMessage("WM_UNCOMPILED");
}

public bool PreFilterMessage(ref Message m)
{
if (m.Msg == wm_compiled)
{
// Do something here for comiled message
}
else if (m.Msg == wm_uncompiled)
{
// Do something here for uncomiled message
}
return false;
}

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern uint RegisterWindowMessage(string lpString);
}
Key Words: compiler compiling compiled uncompiled GraphicsBuilder.ProjectCompile

 

Keywords:
 

Attachments