You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old February 7th, 2018, 01:45 PM   #1
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
Beijer HMI (Scripting)

First time working with one of these units. Software isn't too bad, but I'm a bit stuck on the scripting engine. The documentation isn't very helpful. Do the Script Modules constantly run or must they be called? This application has a "timer" script that gets set true with an interval of 1000, but I don't see the code being executed otherwise tag values should be increasing, and they are not. This application was handed to me as the "latest" from the original programmer.
  Reply With Quote
Old February 7th, 2018, 01:56 PM   #2
Ronnie Sullivan
Member
United Kingdom

Ronnie Sullivan is offline
 
Join Date: May 2010
Location: London
Posts: 450
Which model?
  Reply With Quote
Old February 7th, 2018, 01:59 PM   #3
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
x2 pro 7
  Reply With Quote
Old February 7th, 2018, 03:28 PM   #4
paraffin power
Member
England

paraffin power is offline
 
paraffin power's Avatar
 
Join Date: Aug 2002
Location: Manchester
Posts: 461
It's c# and so event driven.
The script modules are not automatically called, but if you have a timer somewhere this may be calling the sm, or if it doesn't need to be instantiated then maybe just a method in the sm.
In the script module, on the left are events to which methods can be hooked; 'script module created' is a likely candidate for creating a timer event which repeatedly calls other stuff.
Pp
__________________
Whatever hits the fan will not be evenly distributed.
  Reply With Quote
Old February 7th, 2018, 04:11 PM   #5
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
Quote:
Originally Posted by paraffin power View Post
It's c# and so event driven.
The script modules are not automatically called, but if you have a timer somewhere this may be calling the sm, or if it doesn't need to be instantiated then maybe just a method in the sm.
In the script module, on the left are events to which methods can be hooked; 'script module created' is a likely candidate for creating a timer event which repeatedly calls other stuff.
Pp
Actually under script module created, there is nothing. The timer is defined, however, within the script module. I just can't figure out what's calling the script.
  Reply With Quote
Old February 7th, 2018, 04:18 PM   #6
paraffin power
Member
England

paraffin power is offline
 
paraffin power's Avatar
 
Join Date: Aug 2002
Location: Manchester
Posts: 461
I'd be happy to have a quick look. You can mail it if you'd rather not post it.
__________________
Whatever hits the fan will not be evenly distributed.
  Reply With Quote
Old February 7th, 2018, 04:20 PM   #7
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
Quote:
Originally Posted by paraffin power View Post
I'd be happy to have a quick look. You can mail it if you'd rather not post it.
No problem with posting this:
(...and thank you)

Code:
//--------------------------------------------------------------
// Press F1 to get help about using script.
// To access an object that is not located in the current class, start the call with Globals.
// When using events and timers be cautious not to generate memoryleaks,
// please see the help for more information.
//---------------------------------------------------------------

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 TimerScript
	{
		private static Timer timer1 = null;
				
		static TimerScript()
		{
			timer1 = new Timer();
			timer1.Tick += new EventHandler(TimeOut1);
			timer1.Interval = 1000;
			timer1.Enabled = true;			
		}

		public void Stop() 
		{
			try {
				timer1.Enabled = false;
			}
			catch(Exception) {}

			if (Globals.Tags.Running_Status.Value==1)
			{Globals.Tags.Paused.Value = 1;
			Globals.Tags.Elapsed_Time_Color.Value=0;
			}		
			else
			{Globals.Tags.Paused.Value = 0;
			}	
		}
		public void Start()
		{
			try {
				Globals.Tags.ElapsedTime.Value = 0;
				Globals.Tags.ElapsedTimeMin.Value = 0;
				timer1.Enabled = true;
				Globals.Tags.Elapsed_Time_Color.Value=1;
				}
			catch(Exception) {}
		}
		
		public void Resume() 
		{
			try {
				timer1.Enabled = true;
				Globals.Tags.Paused.Value = 0;
				Globals.Tags.Elapsed_Time_Color.Value=1;
			}
			catch(Exception) {}
		}
		
		public void Reset()
		{
			try {
				Globals.Tags.ElapsedTime.Value = 0;
				Globals.Tags.ElapsedTimeMin.Value = 0;
				Globals.Tags.Elapsed_Time_Color.Value=0;
			}
			catch(Exception) {}
		}
		
		private static void TimeOut1(Object myObject, EventArgs myEventArgs) 
		{			
			
			if (Globals.Tags.Running_Status.Value==1)
			{Globals.Tags.ElapsedTime.Value = Globals.Tags.ElapsedTime.Value + 1;
				Globals.Tags.ElapsedTimeMin.Value = Globals.Tags.ElapsedTime.Value / 60;
			}
			if (Globals.Tags.Running_Status.Value==1 &&
					Globals.Tags.CookDone.Value ==0)	
				{Globals.Tags.Step_Elapsed_Time.Value = Globals.Tags.ElapsedTimeMin.Value;
				}
			if (Globals.Tags.Running_Status.Value==1 &&
				Globals.Tags.ElapsedTimeMin.Value>=Globals.Tags.Cook_Time_1.Value &&
				Globals.Tags.Rec_Cook_Time_2.Value >0 &&
				Globals.Tags.CookDone.Value ==0)
			
			{Globals.Tags.Cook_Done1.Value = 1;
			Globals.Tags.Step_Elapsed_Time.Value = (Globals.Tags.ElapsedTimeMin.Value-Globals.Tags.Rec_Cook_Time_1.Value);
			}
			
			if (Globals.Tags.Running_Status.Value==1 &&
				Globals.Tags.ElapsedTimeMin.Value>=Globals.Tags.Cook_Time_2.Value &&
				Globals.Tags.Rec_Cook_Time_3.Value >0 &&
				Globals.Tags.CookDone.Value ==0)
			
			{Globals.Tags.Cook_Done2.Value = 1;
			Globals.Tags.Step_Elapsed_Time.Value = (Globals.Tags.ElapsedTimeMin.Value-Globals.Tags.Rec_Cook_Time_1.Value-Globals.Tags.Rec_Cook_Time_2.Value);
			}
			
			if (Globals.Tags.Running_Status.Value==1 &&
				Globals.Tags.ElapsedTimeMin.Value>=Globals.Tags.Cook_Time_3.Value &&
				Globals.Tags.Rec_Cook_Time_4.Value >0 &&
				Globals.Tags.CookDone.Value ==0)
			
			{Globals.Tags.Cook_Done3.Value = 1;
			Globals.Tags.Step_Elapsed_Time.Value = (Globals.Tags.ElapsedTimeMin.Value-Globals.Tags.Rec_Cook_Time_1.Value-Globals.Tags.Rec_Cook_Time_2.Value-Globals.Tags.Rec_Cook_Time_3.Value);
			}
			
			if (Globals.Tags.Running_Status.Value==1 &&
				Globals.Tags.ElapsedTimeMin.Value>=Globals.Tags.Cook_Time_4.Value &&
				Globals.Tags.Rec_Cook_Time_5.Value >0 &&
				Globals.Tags.CookDone.Value ==0)
			
			{Globals.Tags.Cook_Done4.Value = 1;
			Globals.Tags.Step_Elapsed_Time.Value = (Globals.Tags.ElapsedTimeMin.Value-Globals.Tags.Rec_Cook_Time_1.Value-Globals.Tags.Rec_Cook_Time_2.Value-Globals.Tags.Rec_Cook_Time_3.Value-Globals.Tags.Rec_Cook_Time_4.Value);
			}
			if (Globals.Tags.Running_Status.Value==1 &&
				Globals.Tags.ElapsedTimeMin.Value>=Globals.Tags.Cook_Time_5.Value)
			
			{Globals.Tags.CookDone.Value = 1;
			}
			}			
		void TimerScript_Created(System.Object sender, System.EventArgs e)
		{
			
		}	
	}	
}
  Reply With Quote
Old February 7th, 2018, 04:43 PM   #8
paraffin power
Member
England

paraffin power is offline
 
paraffin power's Avatar
 
Join Date: Aug 2002
Location: Manchester
Posts: 461
The method called TimerScript() has the same name as the class, so it's a constructor. This'll be called automatically. The timer is created here and its Tick (done) is hooked to the Timeout1 method.
Note, some of the methods (Start, Stop, Resume etc) are defined Public, so I guess they're called from script behind screens. Look for 'Globals.TimerScript.Start();' syntax.
Tbh, looks like work that should've been done in the plc but that's my $0.02.
Pp

Edit...something's nagging me about constructors in a partial class. I'll have a quick look in the morning.
__________________
Whatever hits the fan will not be evenly distributed.
  Reply With Quote
Old February 7th, 2018, 04:48 PM   #9
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
Quote:
Originally Posted by paraffin power View Post
The method called TimerScript() has the same name as the class, so it's a constructor. This'll be called automatically. The timer is created here and its Tick (done) is hooked to the Timeout1 method.
Note, some of the methods (Start, Stop, Resume etc) are defined Public, so I guess they're called from script behind screens. Look for 'Globals.TimerScript.Start();' syntax.
Tbh, looks like work that should've been done in the plc but that's my $0.02.
Pp

Edit...something's nagging me about constructors in a partial class. I'll have a quick look in the morning.
So the fact that it's enabled, it doesn't automatically start "ticking" ?
To me, this is different than a normal visual studio app.
I'll poke around for a start, but I cross referenced TimerScript before and nothing else came up. If it just needs the Start, I can easily do that in the main script.
  Reply With Quote
Old February 8th, 2018, 04:53 AM   #10
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
I looked in every screen's script and there is no reference to the TimerScript.Start. But, since you said this gets called automatically, I would assume it get's enabled immediately upon loading, right? The declaration for timer1 includes a timer1.enabled so I would expect to see that going all the time.

None of the graphic screens have any custom scripting behind them, anyway.

Last edited by phuz; February 8th, 2018 at 04:57 AM.
  Reply With Quote
Old February 8th, 2018, 05:11 AM   #11
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
Didn't realize you could do actions directly out of the tag database, but I found it. There is a bit being set in the main script which didn't cross reference to anything else, but I found this box at the very end, and voila!
Attached Images
File Type: png Capture.PNG (17.8 KB, 34 views)
  Reply With Quote
Old February 8th, 2018, 11:42 AM   #12
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
Now I am confused about how the datalogging actually starts. I have it set to collect at periods of 5 seconds, and I have my trend set to use the logged values, but it doesn't start showing the graphs until I go to the trend page, and once I do that, it continues to collect.
  Reply With Quote
Old February 8th, 2018, 01:10 PM   #13
paraffin power
Member
England

paraffin power is offline
 
paraffin power's Avatar
 
Join Date: Aug 2002
Location: Manchester
Posts: 461
Hello
That trigger was well hidden! Well found!
Trending...are the tags set to 'Always Active' in the tag list?
TBH, I thought tags reference in the datalogger had this applied regardless, but I could be wrong.
__________________
Whatever hits the fan will not be evenly distributed.
  Reply With Quote
Old February 8th, 2018, 01:24 PM   #14
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
Quote:
Originally Posted by paraffin power View Post
Hello
That trigger was well hidden! Well found!
Trending...are the tags set to 'Always Active' in the tag list?
TBH, I thought tags reference in the datalogger had this applied regardless, but I could be wrong.
I set them to Always Active, but still same issue.
  Reply With Quote
Old February 8th, 2018, 01:59 PM   #15
phuz
Member
United States

phuz is offline
 
Join Date: Jun 2008
Location: Mohnton, PA
Posts: 736
I confirmed the data logger is collecting data right away, but the graph is only showing data from the time I enter the trend.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Hmi beijer with m221 tasfou@yahoo.gr LIVE PLC Questions And Answers 6 July 18th, 2017 01:30 PM
Beijer HMI archithn LIVE PLC Questions And Answers 4 September 29th, 2015 10:10 AM
TP270 HMI S7-300 CPU 313C-DP Communications drip LIVE PLC Questions And Answers 16 June 21st, 2013 05:36 PM
Beijer E300 HMI Autofabian LIVE PLC Questions And Answers 7 January 23rd, 2011 12:23 AM
E-series HMI and Modems The_Wanderer LIVE PLC Questions And Answers 5 February 25th, 2004 10:46 AM


All times are GMT -5. The time now is 03:19 AM.


.