package Projects.Cible1;

import gpclasses.baseclasses.*;
import gpclasses.system.*;
import gpclasses.macroobjects.*;
import gpclasses.graphics.*;
import gpclasses.animations.*;
import gpclasses.plugins.script.*;
import gpclasses.util.io.*;
import gpclasses.tags.*;
import gpclasses.plugins.diag.*;
import gpclasses.plugins.dialogTable.*;
import gpclasses.userScripts.*;
import gpclasses.plugins.remoteTargetAlarms.*;



public class Startup extends CgpStartup
{
	public static CgpScript DateTime;
	public static Object DateTimeTimerContext;

	// Dialog table member declaration

	public static void main (String args[])
	{
		startupObject = new Startup();
		CgpStartup.main(args);
	}

	public String[] getPublishedPanels()
	{
		return null;
	}

	public int getDisplayWidth()
	{
		return 640;
	}

	public int getDisplayHeight()
	{
		return 480;
	}

	public CgpWindow[] getPopupWindows()
	{
		CgpWindow[] windowList =
		{
			// empty
		};
		return windowList;
	}

	protected void preInitProject()
	{
		TagDB.StaticInit();
		new Projects.Cible1.TagDB();
		CgpSystem.projectName = "Projects/Cible1";
	}

	protected void postInitProject()
	{
		CgpSmartKeypad.setKeypadProperty( true,
						0x00ffffff,
						0x00ffffff,
						0x009f5f1f,
						0x005f3f1f,
						0x00744e14,
						CgpSmartKeypad.LAYOUT_STANDARD
						);

		int iPersistentContext = CgpSystem.TEM.getContextID(0);
		gpclasses.system.CgpSystem.TM.setMinPeriodicInterval(100);
		Projects.Cible1.TagDB._ExternalCmdTag.addEventListener(CgpScript.loadScript("Projects/Cible1/ExternalCmdScript"), 0, iPersistentContext);
		Projects.Cible1.TagDB._CurPanelID.addEventListener(CgpScript.loadScript("gpclasses/system/CgpChangePanelScript"), 0, iPersistentContext);
		DateTime = new CgpDateTimeUpdateScript();
		DateTimeTimerContext = gpclasses.system.CgpSystem.TM.createContext(CgpThread.MAX_PRIORITY-1);
		gpclasses.system.CgpSystem.TM.addTimerScript(DateTime, 1000, DateTimeTimerContext);
		gpclasses.system.CgpSystem.baseWindow.setPanelHistory(32);
		gpclasses.system.CgpSystem.TEM.setAnyHDATags(true);


		CgpTag tagListUsedInProWeb[] =
		{
			TagDB.REG48_PV,
			TagDB.REG48_SV,
		};
		CgpTag tagListIgnoredByProWeb[] =
		{
			TagDB.REG48_PV,
			TagDB.REG48_SV,
		};
		CgpSystem.TEM.registerTagList(iPersistentContext, tagListUsedInProWeb, tagListIgnoredByProWeb);

		char seps[] = {' '};
		CgpLanguageMgr.languageMgr.setSeperators(seps);


		CgpSecurityControl.securityControl = new CgpSecurityControl(
			-1,
			CgpSecurityControl.ACCESS_MIN_LEVEL,
			CgpGraphics.DRAW_SECURED_NOTHING,
			65502,
			CgpSecurityControl.UNSECURED_PANEL_ACTION_NOTHING,
			0,
			0,
			false,
			false,
			true);
		CgpSecurityControl.securityControl.init();
		byte [] securityKey = {102,51,102,98,57,98,54,97,101,57,55,54,50,102,97,48,101,98,101,97,102,53,57,97,102,50,48,48,53,97,48,51,52,100,98,53,49,49,97,52,};
		CgpSecurityDB.securityDB = new CgpSecurityDB(securityKey);
		CgpSecurityDB.securityDB.init();
		if (CgpSystem.isPlatform(CgpSystem.HMI)) CgpHdaHistorian.setAutoFlushTime(1050);

		// Dialog Table Functions

		gpclasses.system.CgpSystem.globalCursor = new CgpCursor("MouseArrow.bmp", "MouseHand.bmp", 20, 25, CgpColor.makeTransparentColor(0x00333333));

		gpclasses.system.CgpSystem.globalCursor.setTimeout(30);
	}

	protected void openScripts()
	{
	}

	protected void shutdownProject()
	{
		TagDB.GroupeAlarmes1.clean();
	}

}
