Page 1 of 2

How to change screen with script

Posted: Thu Jul 05, 2012 4:43 am
by memethemyn
Hi..

In my project to open the Alarms page I want to use script. Because first I control the alarm bit then if the alarm bit set I wll show the Alarms page.. How can I show screen in the script.

The code is below:

Code: Select all

if ( Globals.Tags.Alarm_Bit.Value == 0) 
{
MessageBox.Show("No Active Alarms !", "No Alarm",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
---- The code to show Alarms screen  -----

}





Re: How to change screen with script

Posted: Thu Jul 05, 2012 8:33 am
by Ron L.
The code to show a screen looks like this.

Code: Select all

Globals.Screen1.Show();
Substitute the name of the screen you want to show for "Screen1".

Re: How to change screen with script

Posted: Fri Jul 06, 2012 5:01 am
by memethemyn
Thanks for your reply mr Ron..

But I have a question again about scripting..

For example we have many of recipes and want to load a default recipe each system is powered on. So I have to write script for this but I didn't find what code to write into script. Please help..

Thanks already..

Mehmet.

Edit: I Found the code

Code: Select all

Globals.Recipe.LoadRecipe(@"Recipe name");
Will be helpful..

Thanks

Re: How to change screen with script

Posted: Fri Jul 06, 2012 8:12 am
by Ron L.
Use the screen opened action of your startup screen.
Snap 2012-07-06 at 09.11.47.jpg
Snap 2012-07-06 at 09.11.47.jpg (67.84 KiB) Viewed 28492 times

Re: How to change screen with script

Posted: Mon Jul 09, 2012 4:34 am
by memethemyn
Hi Mr. Ron..

I need a script again to log database once at the test start :(

Thanks already..

Re: How to change screen with script

Posted: Mon Jul 09, 2012 7:49 am
by mark.monroe
You could create a timer and turn the timer on and off via a button. That timer could increment a tag which is used to tell the datalogger to log data.

If you set the timer for 1 minute, when the timer is enabled, then every minute the timer will change the value of the event tag, and the datalogger will log some data. You just need to set the "Log on Tag event" of your datalogger to the tag that is being incremented via a timer.
Snap 2012-07-09 at 08.41.45.jpg
Snap 2012-07-09 at 08.41.45.jpg (45.91 KiB) Viewed 28481 times

Re: How to change screen with script

Posted: Thu Jul 12, 2012 2:21 am
by memethemyn
Hi...

I don't want to open a new topic for my problem.. Anybody help me about changing font color of a button via script?

I tried to use Button1.Fontcolor but I didn't find what I must write after this code..

Thanks Already..

Re: How to change screen with script

Posted: Thu Jul 12, 2012 6:36 am
by mark.monroe
Try This:

Code: Select all

this.Button1.FontColor = new BrushCF(Color.Aqua);

Re: How to change screen with script

Posted: Thu Jul 12, 2012 11:25 pm
by memethemyn
Dear Mark..

Thanks for you for replies I know that I ask many question but I near to finish my project in 2 weeks. So; here is a problem that waiting me as creating test reference number.. For example; I want to give a reference number to my test as date.

Eg. Today is 13/07/2012 Time is 09:30 in this situation I want to create a reference number as 130712-0930..

I hope to help me about this problem..

Thanks..

Re: How to change screen with script

Posted: Fri Jul 13, 2012 7:15 am
by mark.monroe
The below code will convert the SystemTagDateTime, which is a tag that reports the current time on the HMI, to the format that you want.

To log this value into the datalogger, you will need to add the tag, RefID, to your test. Then it will show up as a column in the datalogger output.

You will need to decide on how you want to trigger the code. You could do it as part of a button that starts your test for example. Or you could put it in the value change event of the SystemTagDateTime tag.

Click for more info on DateTime formating

Code: Select all

Globals.Tags.RefID.Value = ((DateTime) Globals.Tags.SystemTagDateTime.Value).ToString("ddMMyy-hhmm");
Snap 2012-07-13 at 08.07.31.png
Snap 2012-07-13 at 08.07.31.png (108.49 KiB) Viewed 28457 times