how to retrieve a value in a tag and transfer in another tag

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
yannick622
Posts: 7
Joined: Mon Jun 04, 2018 8:15 am

how to retrieve a value in a tag and transfer in another tag

Post by yannick622 »

HI,I need your help to complete a program.
I need to retrieve a value from a tag at a T time that is constantly changing (Conso of the month).
this value goes back to zero every 1st of the month. I must therefore recover the max value of the month.
this value must be put in the Tag of the corresponding month (January, February, ...)
I tried with the scheduler to retrieve this value and put it in another tag (June), but the value is displayed at 1.
so I need your help to solve this problem, could you help me over it.

so How to pick a value a at T time in a tag and set this value in another Tag (june per example)?
this tag(june) is not used in a controller, it only used for display
thanks for your help
yannick
Attachments
Sans titre.jpg
Sans titre.jpg (133.46 KiB) Viewed 9788 times

User avatar
Russ C.
Posts: 213
Joined: Thu Nov 16, 2017 3:32 pm
Contact:

Re: how to retrieve a value in a tag and transfer in another

Post by Russ C. »

I would use the SystemTagMonth and check the value changes on that one and your KWh tag. I would write something like this:

Code: Select all

void MyValue_ValueChange(System.Object sender, Core.Api.DataSource.ValueChangedEventArgs e)
		{
			if(MyValue.Value > MonthMaxValue.Value)
			{
				MonthMaxValue.Value = MyValue.Value;
			}
		}
		
		void SystemTagMonth_ValueChange(System.Object sender, Core.Api.DataSource.ValueChangedEventArgs e)
		{
			switch(SystemTagMonth.Value)
			{
				//When the month value changes, set the highest value to the previous month max value
				case 1:
					DecMaxValue.Value = MonthMaxValue.Value;
					break;
				case 2:
					JanMaxValue.Value = MonthMaxValue.Value;
					break;
				case 3:
					FebMaxValue.Value = MonthMaxValue.Value;
					break;
				case 4:
					MarMaxValue.Value = MonthMaxValue.Value;
					break;
				case 5:
					AprMaxValue.Value = MonthMaxValue.Value;
					break;
				case 6:
					MayMaxValue.Value = MonthMaxValue.Value;
					break;
				case 7:
					JunMaxValue.Value = MonthMaxValue.Value;
					break;
				case 8:
					JulMaxValue.Value = MonthMaxValue.Value;					
					break;
				case 9:
					AugMaxValue.Value = MonthMaxValue.Value;
					break;
				case 10:
					SepMaxValue.Value = MonthMaxValue.Value;
					break;
				case 11:
					OctMaxValue.Value = MonthMaxValue.Value;
					break;
				case 12:
					NovMaxValue.Value = MonthMaxValue.Value;
					break;		
			}
			
			//Once the MonthMaxValue has been stored to the correct month, reset its value for the new month
			MonthMaxValue.Value = 0;
			
		}



Best regards,

Russ
(801) 708-6690
Technical Support
Contact Us

Beijer Electronics AB
http://www.beijerelectronics.us

yannick622
Posts: 7
Joined: Mon Jun 04, 2018 8:15 am

Re: how to retrieve a value in a tag and transfer in another

Post by yannick622 »

Hi Mr Russ, thanks for your help.
i'm very beginner in script and trying to understand.

MyValue = that's the tag of my "conso mois"
and each DecMaxValue, JanMaxValue... refer to my tags december, janvier...
?

MonthMaxValue, Month is define by the systemTagMonth ?

so if i understand well, i have to rename my months tags with DecMaxValue, JanTagvalue.... or replace those words with the tags names of my choice in the script?

Do i have to create the tag "SystemTagMonth" in my tag list?

and last question, does the tag SystemTagWeek exist?

thanks a lot
yannick

yannick622
Posts: 7
Joined: Mon Jun 04, 2018 8:15 am

Re: how to retrieve a value in a tag and transfer in another

Post by yannick622 »

hi, i have a script error when i'm compil this one:
CS0103: le nom "MyValue" n'existe pas dans le contexte actuel.

sorry, but i'm really a beginner in script.

thanks
Attachments
Sans titre.png
Sans titre.png (286.32 KiB) Viewed 9763 times

User avatar
Russ C.
Posts: 213
Joined: Thu Nov 16, 2017 3:32 pm
Contact:

Re: how to retrieve a value in a tag and transfer in another

Post by Russ C. »

Oh, sorry for the confusion, that script I provided should be placed on the Tags Script page. You have it on the ConsoAspiration script page.
Best regards,

Russ
(801) 708-6690
Technical Support
Contact Us

Beijer Electronics AB
http://www.beijerelectronics.us

User avatar
Russ C.
Posts: 213
Joined: Thu Nov 16, 2017 3:32 pm
Contact:

Re: how to retrieve a value in a tag and transfer in another

Post by Russ C. »

Also once its on the Tags Script page, make sure you either name your tags the same as what is in the script or change the script to match your tags and you will need to hook up the event handlers for the SystemTagMonth_ValueChange and the MyValue_ValueChange. See below:
store-highest-montly-value.png
store-highest-montly-value.png (89.9 KiB) Viewed 9762 times
Best regards,

Russ
(801) 708-6690
Technical Support
Contact Us

Beijer Electronics AB
http://www.beijerelectronics.us

yannick622
Posts: 7
Joined: Mon Jun 04, 2018 8:15 am

Re: how to retrieve a value in a tag and transfer in another

Post by yannick622 »

Hi, after some time to manipulate Ix developer, and made some change. the program seems to work fine.

finaly, my tag where the total power was stored, was never reset at the end of the month. so i created a new tag (IndexMonth) where i stored the Max value of the previous month and used this value to calculate the next month :

the script is like that:

case 1:
DecMaxValue.Value = MonthMaxValue.Value-IndexMonthMaxValue.Value;
IndexMonthValue.Value=MonthMaxValue.Value;
break;

But now i have an other problem, when i transfert the updated program or when i restart the panel, the month values and the index value are set to "0".

I don't understand why, i used the this parameters "int32", "non volatile"

could you explain me why this values are set to "0" each time i restart the panel
Maybe there is something to set or the script to change?

thanks for your help.
yannick

yannick622
Posts: 7
Joined: Mon Jun 04, 2018 8:15 am

Re: how to retrieve a value in a tag and transfer in another

Post by yannick622 »

Finally after a lot of test and change the month value stay at each program transfert.
all but not the previous month. i'm explain:

actually, i'm in the case 6 (june)
so with this code, when i transfert the program, i'have "0" in "Index Mois" and "Mai"
M34ConsoMai.Value = MonthMaxValueM34.Value-IndexPreviousMonthM34.Value;
IndexPreviousMonthM34.Value = MonthMaxValueM34.Value;
break;

If i clear the second line (IndexPreviousMonthM34.Value = MonthMaxValueM34.Value)
i have "Index Moi" That stay at 8 and "Mai" that show "-8"

Why??
Attachments
mai screen.jpg
mai screen.jpg (273.95 KiB) Viewed 9676 times

yannick622
Posts: 7
Joined: Mon Jun 04, 2018 8:15 am

Re: how to retrieve a value in a tag and transfer in another

Post by yannick622 »

me again,

i manipulated a lot this weekend.

and now, it's seems to stay only one problem, when i transfert the program to the HMI, the program seems to consider that the month has changed and does the calculation of the previous month.
is it possible to tell the script to ignore the first month change?

thanks
yannick

Post Reply