cancel
Showing results for 
Search instead for 
Did you mean: 

Flip String

Former Member
0 Kudos

Dear all,

from a scale I get the result as a string in the following way:

gk017.000+

Is there a possibility to flip it to

+000.710kg

in a transaction? With a built in function?

of course I can do it in a comlicated way (e.g. assigning every single fugure to a transaction variable and assemble it again; or using stringleft(string , length) to assemble it) but is there a function which can do this?

Regards,

Martin

Accepted Solutions (1)

Accepted Solutions (1)

former_member196557
Active Contributor
0 Kudos

Where are you getting the scale string from, directly from the scale or via a PLC/OPC Tag query? I would be very surprised if the scale is outputing a reversed-order string. If it is PLC/OPC could be the PLC is not properly receiving the data.

I would focus on getting the format fixed prior to processing in MII.

- Steve

Former Member
0 Kudos

Hi Steve!

Thanks for your quick reply!

But unfortunately I really get it like this from the scale.

It says so even in the manual of the scale. Please don´t ask me why!!! I was stunned too.

Is there a possibility to turn it around in the OPC? I would prefer this of course.

Currently I´m doing it in this way:

stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 10 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 9 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 8 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 7 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 6 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 5 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 4 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 3 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 2 , 1)
 & stringpart(tag_waageRxD_0.Results{/Rowsets/Rowset/Row/RxD} , 1 , 1)

Luckily the scale always returns the same amount of digits.

Regards,

Martin

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Martin,

You could consider building a simple utility transaction that you could call when you need it. Just for experimentation purposes, I built one that consists of 2 action blocks, a stringIn and a stringOut transaction property.

The first action block uses a For_Next_Loop that is configured with To = 1 and Step = -1. In the Link Editor for this, I assign the length of the string to the From property of the loop:

stringlength(Transaction.stringIn)

Then, I use an Assignment block to concatenate the string in reverse order, and assign it to the Transaction.stringOut property:

Transaction.stringOut & stringpart(Transaction.stringIn, For_Next_Loop_0.CurrentItem, 1)

What is nice is that the length of the string does not matter. Just a suggestion

Kind Regards,

Diana Hoppe

Former Member
0 Kudos

If you have a db connection, you could try

SELECT REVERSE('AB')  AS VALUE

for sql server

or

SELECT REVERSE('AB')  AS VALUE FROM DUAL

for oracle

former_member196557
Active Contributor
0 Kudos

Martin,

If the scale is connected to a PLC or OPC it may be possible to reverse the order in either of those. so:

scale vendor/model?

PLC vendor/model?

OPC Server vendor/version?

- Steve

Former Member
0 Kudos

Thanks Steve!

Scale is a very cheap one:

MAUL logic S:

Transfer:
At every call-up 11 Bytes are transferred.
2 bytes ASCII ; codes the weight unit g, kg, oz or lb.
7 bytes ASCII; codes the weight value including the comma and point
1 byte codes the sign
1 byte codes the carriage return.
Example for the transfer:
g^7300000+ ASCII 13, gives 73g
( ^means a space) bl3.10:20+ ASCII 13, 2lb and 1.3oz
----^^^^^^ASCII 13, ---- under load
LLUF^^^^^^ASCII 13, FULL overload
(Tip: If you hold the key longer than 5 seconds, when the scales is turned off, then you switch
the scales between kg/g and lb/oz and vice versa.
Calculation: 1oz= 28,35g 1lb= 453,59g 1lb= 16oz

ComServer from W&T (WUT), Wiesemann&Theis (Com-Server Highspeed Industry) via LAN/RS232.

OPC is also W&T (WUT), Wiesemann&Theis, Version 4.31

UDS is from SAP.

Martin

former_member196557
Active Contributor
0 Kudos

OK, you have stumped me now. I am not familiar with the WuT product line. Unless there is some documentation that comes with the Com-Server to indicate how to modify the string format, you will have to use the current design and character-swap within MII transaction. Hopefully this will not impact performance.

My guess is that the scale outputs the reverse format to support another product they offer like a printer.

- Steve