Start Data Logger automatically on bootup

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
onedumbtrucker
Posts: 14
Joined: Thu Nov 14, 2013 12:14 pm

Start Data Logger automatically on bootup

Post by onedumbtrucker »

Hi,

I am trying to figure out how to start my data log on startup of the application. Is there any way to access the Event Handler for the main program load? Or is there some internal system tag like a First Scan tag?

I have tried putting the log start in the opened event handler for my start up screen but I do not want it to start the logger every time that screen is access so I tried the following;

void Home_Screen1_Opened(System.Object sender, System.EventArgs e)
{
if(!Globals.OneWeekAt30SecondIntervals.IsEnabled && Globals.Tags.SystemTagUsedStoragePercent.Value < 90)
{
Globals.OneWeekAt30SecondIntervals.Start();
}
}

But of course this does not work because the .IsEnabled property is not the same as asking if it is currently logging. I know I could just have it start regardless everytime the Home_Screen_Opened is called but that is bad programming and I am not sure if the logger creates a new log or appends the existing one when the .Start() is called.

I come from a strong C# programming background so I may end up opening the program in Visual Studio and hacking in the call I want where I want but I was hoping there was an easy way to do this.

There should be setting in the data logger settings to enable on start instead of relying on putting a .Start() in somewhere. Even if there was a way to trigger it on establishing good communications with the Controller this would be acceptable but I would still need to condition so that it does not need to call the .Start() every time.

User avatar
Edmund
Posts: 92
Joined: Thu Nov 29, 2012 2:27 pm

Re: Start Data Logger automatically on bootup

Post by Edmund »

If you are using the built in datalogger it is started on bootup.

Just enter the interval (in seconds) you want to have between each log.
Datalogger -> Settings



If you want to do someting once at startup you can do it in the constructor / created event (not a real constructor but anyway) of a scripmodule.

Code: Select all


namespace Neo.ApplicationFramework.Generated
{
    using System.Windows.Forms;
    using System;
    using System.Drawing;
    using Neo.ApplicationFramework.Tools;
    using Neo.ApplicationFramework.Common.Graphics.Logic;
    using Neo.ApplicationFramework.Controls;
    using Neo.ApplicationFramework.Interfaces;
    
    
    public partial class ScriptModule1
    {
		
		void ScriptModule1_Created(System.Object sender, System.EventArgs e)
		{
			// Runs once
		}
    }
}


Or if you don´t want to have it ther (becuse sometimes it´s happens to earliy at the startup) you could do somwting like this and call it each time you enter the start screen but it will once fire the method "ConquerTheWorld" once.

Code: Select all

 public partial class ScriptModule1
    {
		private bool init = false;
		
		public void MyInitFunction()
		{
			if(!init)
			{
				ConquerTheWorld();
				init = true;
			}
		}
		
		private void ConquerTheWorld()
		{
			// Runs once
		}
    }
And the call

Code: Select all

void Screen1_Opened(System.Object sender, System.EventArgs e)
		{
			Globals.ScriptModule1.MyInitFunction();
		}
Edmund Andersson

AITECH AB

Part of Beijer Integrator Group

npo
Posts: 1
Joined: Thu Mar 12, 2015 2:22 am

Re: Start Data Logger automatically on bootup

Post by npo »

Hi

I have tried to follow the exampel to get som Init code to run under tags script.

private static int counter = 0;
void Tags_Created(System.Object sender, System.EventArgs e)
{
counter ++;

}
But the counter never counts.

Post Reply