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
how to retrieve a value in a tag and transfer in another tag
-
- Posts: 7
- Joined: Mon Jun 04, 2018 8:15 am
how to retrieve a value in a tag and transfer in another tag
- Attachments
-
- Sans titre.jpg (133.46 KiB) Viewed 12872 times
Re: how to retrieve a value in a tag and transfer in another
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
Russ
(801) 708-6690
Technical Support
Contact Us
Beijer Electronics AB
http://www.beijerelectronics.us
-
- Posts: 7
- Joined: Mon Jun 04, 2018 8:15 am
Re: how to retrieve a value in a tag and transfer in another
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
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
-
- Posts: 7
- Joined: Mon Jun 04, 2018 8:15 am
Re: how to retrieve a value in a tag and transfer in another
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
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 (286.32 KiB) Viewed 12847 times
Re: how to retrieve a value in a tag and transfer in another
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
Russ
(801) 708-6690
Technical Support
Contact Us
Beijer Electronics AB
http://www.beijerelectronics.us
Re: how to retrieve a value in a tag and transfer in another
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:
Best regards,
Russ
(801) 708-6690
Technical Support
Contact Us
Beijer Electronics AB
http://www.beijerelectronics.us
Russ
(801) 708-6690
Technical Support
Contact Us
Beijer Electronics AB
http://www.beijerelectronics.us
-
- Posts: 7
- Joined: Mon Jun 04, 2018 8:15 am
Re: how to retrieve a value in a tag and transfer in another
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
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
-
- Posts: 7
- Joined: Mon Jun 04, 2018 8:15 am
Re: how to retrieve a value in a tag and transfer in another
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??
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 (273.95 KiB) Viewed 12760 times
-
- Posts: 7
- Joined: Mon Jun 04, 2018 8:15 am
Re: how to retrieve a value in a tag and transfer in another
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
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