УкраїнськаEnglishmRussian
Вхід/Новий
У темі багато повідомлень

Problems of Adaption


Автор Повідомлення
Повідомлення створено: 04. 08. 2009 [21:17]
Unaie
Unai Ezta
Автор теми
Зареєстрован(а) с: 30.06.2009
Повідомлення: 42
Oscada looks a great SCADA, but I have some problems starting with it.

1. How to do correctly in OSCADA two PUSH BUTTONS: start, stop?
They must send a signal TRUE for x miliseconds and then FALSE, and after NOTHING.

My "solution" is this, but I think is not ideal, because is always sending FALSE if there are not events.



JAVASCRIPT
ev_cur = ev_rez = "";off = 0;
 
Close_value=false;Open_value=false;
 
while(true)
{
  ev_cur=Special.FLibSYS.strParse(event,0,"\n",off);
  if( ev_cur == "" ) break;
  else if ( ev_cur == "ws_BtPress:/Close")
  {
    Close_value= true;
  }
  else if( ev_cur == "ws_BtPress:/Open")
  {
      Open_value=true;
  }
  else ev_rez+=ev_cur+"\n";
}
event=ev_rez;



2. How to process a value in a Line Input (ElForm Widget) after read and before write?

I am using modbus, it does not read Real values (Float 32 bits), so I need
to do a conversion float/integer after read and before write to PLC.



JAVASCRIPT
ev_cur = ev_rez = "";off = 0;
 
while(true)
{
  ev_cur=Special.FLibSYS.strParse(event,0,"\n",off);
  if( ev_cur == "" ) break;
  else if (ev_cur=="ws_LnAccept:/LineInput")
  {
     PLCValue=(LineInput_value*100)+27315; //Float To Integer
  }
 
  else ev_rez+=ev_cur+"\n";
}
event=ev_rez;
 
LineInput_value=(PLCValue-27315)/100; //Integer to Float


The problem is that it is setting LineInput_value continuously and there are problems when you want to change this value in display.


3. How to Input numeric data in a touch screen? is there a screen keyboard or any other solution?


These are my questions just now.
-----------------------

I am using Oscada and Modbus to communicate with a SoftPLC Beckhoff Twincat.




Повідомлення створено: 05. 08. 2009 [17:12]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
Unaie wrote:

My "solution" is this, but I think is not ideal, because is always sending FALSE if there are not events.


Use time delay counter from call frequency attribute "f_frq" or store click time and check from current time for "false" set by function "tmTime()"

JAVASCRIPT
using Special.FLibSYS;
 
ev_cur = ev_rez = "";off = 0;
 
if( Close_value && tmTime() > (CloseTm+x) ) Close_value=false;
if( Open_value && tmTime() > (OpenTm+x) ) Open_value=false;
 
while(true)
{
  ev_cur=Special.FLibSYS.strParse(event,0,"\n",off);
  if( ev_cur == "" ) break;
  else if ( ev_cur == "ws_BtPress:/Close")
  {
    Close_value= true;
    CloseTm = tmTime();
  }
  else if( ev_cur == "ws_BtPress:/Open")
  {
      Open_value=true;
      OpenTm = tmTime();
  }
  else ev_rez+=ev_cur+"\n";
}
event=ev_rez;


Unaie wrote:

I am using modbus, it does not read Real values (Float 32 bits), so I need
to do a conversion float/integer after read and before write to PLC.



For that function floatMergeWord set. But on x86_64 trivial conversion code work error:
char vl[4];
*(ui16*)vl = val->getI(1);
*(ui16*)(vl+2) = val->getI(2);
float fvl = *(float*)vl;

Unaie wrote:

The problem is that it is setting LineInput_value continuously and there are problems when you want to change this value in display.

No problem. In time user changing value this field will locked.

Unaie wrote:

3. How to Input numeric data in a touch screen? is there a screen keyboard or any other solution?

Use right-side buttons for increase and decrease value.

Learn, learn and learn better than work, work and work.
Повідомлення створено: 06. 08. 2009 [10:10]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
roman wrote:

Unaie wrote:

I am using modbus, it does not read Real values (Float 32 bits), so I need
to do a conversion float/integer after read and before write to PLC.

For that function floatMergeWord set. But on x86_64 trivial conversion code work error:
char vl[4];
*(ui16*)vl = val->getI(1);
*(ui16*)(vl+2) = val->getI(2);
float fvl = *(float*)vl;

Build project with key -O1 without -O2 and all will work.

Learn, learn and learn better than work, work and work.
Повідомлення створено: 06. 08. 2009 [17:42]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
Roman wrote:

Unaie wrote:

The problem is that it is setting LineInput_value continuously and there are problems when you want to change this value in display.

No problem. In time user changing value this field will locked.

This is real problem on last QT. Now it is fixed, work and "Apply" button appear.

Learn, learn and learn better than work, work and work.
Повідомлення створено: 07. 08. 2009 [12:53]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
roman wrote:

Build project with key -O1 without -O2 and all will work.

Corrected for build with -O2.

Learn, learn and learn better than work, work and work.
Повідомлення створено: 18. 08. 2009 [20:54]
Unaie
Unai Ezta
Автор теми
Зареєстрован(а) с: 30.06.2009
Повідомлення: 42
roman wrote:

Corrected for build with -O2.


Tested with SVN and all OK.

I am using a x86 32 bits, and now it is possible to use floatMergeWord and floatSplitWord in order to use REALs with Modbus.


I put here my trick, How to use transparently FLOAT values with Modbus:

1. In Modbus define the TWO Registers (16 bits) linked to ONE REAL (32 bits) in PLC

R:12288:rw:R1
R:12289:rw:R2

2. In DAQ Templates

---------------------
R1 R1 Integer Output Full Access Link
R2 R2 Integer Output Full Access Link
R R Real Output Full Access Constant 0
R_old R_old Real Output No Attribute Constant 0
------------------------

JAVASCRIPT
//Float To 2R. This for Write 
if (R_old!=R)  Special.FLibSYS.floatSplitWord(R,R1,R2); 
 
//2R To Float. This for Read
R=Special.FLibSYS.floatMergeWord(R1,R2); 
R_old=R;


3. In DAQ Logic Level create a Parameter using previous Template
and link R1 and R2 to previous ModBus Paths R1 and R2.

New Paths in VCA are prm:/logiclevel/../R , instead of prm:/modbus/../R1 and R2, and you can read and write floats transparently.





Повідомлення створено: 19. 08. 2009 [11:34]
Unaie
Unai Ezta
Автор теми
Зареєстрован(а) с: 30.06.2009
Повідомлення: 42
Unaie wrote:


2. In DAQ Templates

---------------------
R1 R1 Integer Output Full Access Link
R2 R2 Integer Output Full Access Link
R R Real Output Full Access Constant 0
R_old R_old Real Output No Attribute Constant 0
------------------------

JAVASCRIPT
//Float To 2R. This for Write 
if (R_old!=R)  Special.FLibSYS.floatSplitWord(R,R1,R2); 
 
//2R To Float. This for Read
R=Special.FLibSYS.floatMergeWord(R1,R2); 
R_old=R;


3. In DAQ Logic Level create a Parameter using previous Template
and link R1 and R2 to previous ModBus Paths R1 and R2.




I have seen that there is a problem with this.

Oscada is writing continuosly R1 and R2 values in PLC, not only when
condition (R_old!=R) is true, so you cannot externally change this values because they are reestablished again.

Is this a bug? or this idea is wrong? in that case, what is the correct solution?


Повідомлення створено: 20. 08. 2009 [09:21]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
Unaie wrote:

I have seen that there is a problem with this.

Oscada is writing continuosly R1 and R2 values in PLC, not only when
condition (R_old!=R) is true, so you cannot externally change this values because they are reestablished again.

Is this a bug? or this idea is wrong? in that case, what is the correct solution?

No bug. It is continuosly process and the writer must be single. One note, DAQ-module would not write to PLC equal value to previous.

Learn, learn and learn better than work, work and work.
Повідомлення створено: 20. 08. 2009 [10:05]
Unaie
Unai Ezta
Автор теми
Зареєстрован(а) с: 30.06.2009
Повідомлення: 42
roman wrote:

Unaie wrote:

I have seen that there is a problem with this.

Oscada is writing continuosly R1 and R2 values in PLC, not only when
condition (R_old!=R) is true, so you cannot externally change this values because they are reestablished again.

Is this a bug? or this idea is wrong? in that case, what is the correct solution?

No bug. It is continuosly process and the writer must be single. One note, DAQ-module would not write to PLC equal value to previous.


And why I cannot change externally these values?

A sample, R=21.75, Oscada is reading this value, and I change this value in PLC to 17.00, then Oscada reestablish 21.75 again. I don't understand. if write line is commented there is not difference.

JAVASCRIPT
//if (R_old!=R) Special.FLibSYS.floatSplitWord(R,R1,R2);
 
R=Special.FLibSYS.floatMergeWord(R1,R2);
R_old=R;


1. Change in PLC to 17.00
2. Oscada read modbus (R1,R2)=17.00
3. Javascript initial state:

R=R_old=21.75
(R1,R2)=17.00

4. Javascript final state:
R=R_old=17.00
(R1,R2)=17.00

5. There is not change in (R1,R2). Then, why does Oscada writes again R1 and R2, and why 21.75?




PS: After a new Test... Really you can comment all javascript code.
Necessary and sufficient condition is R1,R2 declared as OUTPUT LINK and Logic Level Parameter Link to ModBus Enabled. Then old values are always reestablished.









[Повідомлення редагувалось 1 раз(ів), останній раз 20.08.2009 в 10:16.]
Повідомлення створено: 20. 08. 2009 [13:03]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
Unaie wrote:

PS: After a new Test... Really you can comment all javascript code.
Necessary and sufficient condition is R1,R2 declared as OUTPUT LINK and Logic Level Parameter Link to ModBus Enabled. Then old values are always reestablished.

With script all work fine:
JAVASCRIPT
if( R_old != R && R != EVAL_REAL ) Special.FLibSYS.floatSplitWord(R,R1,R2); 
R_old = R = (R1==EVAL_INT || R2==EVAL_INT) ? EVAL_REAL : Special.FLibSYS.floatMergeWord(R1,R2);


P.S. I add writing to PLC only if value is new and not equal EVAL.

Learn, learn and learn better than work, work and work.



14301