cancel
Showing results for 
Search instead for 
Did you mean: 

Visiprise 4.2 Router scripting

Former Member
0 Kudos

Hi,

Iam experimenting with the router scripting capabilities and was woundering if there is any other documentation apart from the appendix in the setting up a production line guide ??

Im trying to create a router that incudes an automatic sample plan. EG a 10% sample of products in a shop order would carry out an addition operation .

The way I have our system configured is that each SFC is a qty of 1 ie a single SFC for each product .

So far I have written a script that uses the executeQuery to perform several checks

1) First I use the SFC and query the live database to find what shop order it belongs to

2) I then query it again to find the qty_released for that Shop order

3) I query it again to give me the count of SFC's in the same Shop order that have completed the operation .

From these I plan to use some simple logic to work out if the product should carry out the additional step or not.

My problem is that I have all 3 querys working fine however I want to pass the result from one query to the next query.

I tried doing this by concatinating the variable from one query into the next but I have an issue with the shop order query ! It returns a string containing more than jsut the shop order, off the top of my head it was something like

"SHOP_ORDER{java............}=12345"

so I wanted to strip the first 29 characters off this string so I tried

var ShopOrder=executeQuery("blah blah blah")

print(ShopOrder.substring(29))

I checked the syntax and it said it was OK but when I tested it in a router It gave me an error saying it didnt know what substring was , I also tried substr() and it also didnt like that .

Im not too familiar with java script but I progam alot in vb.net so its pretty similar .

Do I need to import a java class that handles string manipulation ??

Ive been on the mozilla Rhino site trying to find info as well but got no where.

Thanks for any help you can give.

Kev 🐵

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Ah , just noticed that my message has been converted to a weblink !!

The repsonse from the print(find_shop_order)

should read SHOP_ORDER{java.lang.String}=20100913-20

can I convert this data object directly into a string ?

Kev

Former Member
0 Kudos

Kev

Try

shopOrder = find_shop_order.getString("SHOP_ORDER", "");

Former Member
0 Kudos

Stuart,

shopOrder = find_shop_order.getString("SHOP_ORDER", ""); worked a treat 🐵 thank you . I now need to work out how to send you a virtual beer

However I also tried

alarmData = new Data();

alarmData.put("SITE", SITE);

alarmData.put("EVENT_DATE", new java.util.Date());

alarmData.put("MESSAGE_TEXT", "message from kev");

callEJB("AlarmBO", "send", alarmData);

and it threw an error on the POD which said "Script Error: undefined: "Data" is not defined. " for the line alarmData = new Data();

Any ideas on that one ???

I assume you also have to send ALARM_TYPE_CONFIG_BO to it as well ? And create an alarm type in the activity manager ?

Thanks

Kev

Former Member
0 Kudos

Kev

Just insert:

importClass(Packages.com.genrad.frame.Data);

at the start of your script, then you can use Data objects.

You will need the ALARM_TYPE_CONFIG_BO - just as you see it in the database. So, do something like:

alarmData.put("ALARM_TYPE_CONFIG_BO", "AlarmTypeConfigBO:" + SITE + ",true,APP_INFO");

if you want to use the APP_INFO event. Note I made use of the SITE variable here - that helps to make the script transportable between sites.

Former Member
0 Kudos

Stuart, thats another beer I owe you

Worked perfectly, its a bit of a pain getting to the data but I can live with that as its only for debugging.

Now if only I could write a message to the POD .............................

Kev 🐵

Answers (4)

Answers (4)

Former Member
0 Kudos

Just a quick update, Ive found an easier way of passing meaages to my self for diagnostics 🐵

importClass(Packages.com.genrad.app.utils.MailMessage)

mailstring = "SFC :"+SFC

"\nQTY :"QTY

"\nLoop Count :"LOOP_COUNT

"\nOperation :"OPERATION

"\nTo Operation :"TO_OPERATION

"\nResource :"RESOURCE

"\nSite :"SITE

"\nItem :"ITEM

"\nUser :"USER

"\nElapsed Time :"ELAPSED_TIME

"\nElapsed Queue Time :"ELAPSED_QUEUE_TIME

email = new MailMessage(EmailToAddress,EmailFromAddress,"Message From VM",mailstring,SMTP Host IP Address)

email.sendMessage()

Kev

Former Member
0 Kudos

I just had a look at the AlarmTypeConfigBo table and Im going to try using the APP_INFO type to save me setting a new one up and its severity is set to 300 (Info) its handle is "AlarmTypeConfigBO:*,true,APP_INFO" is that what I pass for the ALARM_TYPE_CONFIG_BO or do I strip off the AlarmTypeConfigBO: from the front and pass *,true,APP_INFO ??

Sorry for the constant stream of questions, Im new to this and I have an inquisitive mind !

Kev

Former Member
0 Kudos

OK, I will give that a try but out of curiosity can I get the substring of a variable in the script ?

The setting up a production documentation says that the script langauge is Rhino and according to the Rhino documentation you use substring() but it doesn't work.

The sample plan is one application that I can use this for but I have some others that Im thinking about as well.

Also is there anyway of getting the script to display a message to the user either on the POD or a pop up window ??

Im currently using print() which displays what Im looking for in the weblogic console on the server , I am a system admin but I don't have access to the server , I keep having to get someone else to tell me whats on the console.

Thanks

Kev

Former Member
0 Kudos

The WL log file could be redirected to a shared folder - that is just configuration in the WL console.

Alternatively, you could get the script to create a Visiprise Manufacturing event and then you could see the trace in the Event Viewer. This is a bit messy, but easy to do. - you need to call the EJB that creates an alarm from the script:

callEJB("AlarmBO", "send", alarmData);

where alarmData is a data object. This requires quite a few preparatory statements, e.g.

alarmData = new Data();

alarmData.put("SITE", SITE);

alarmData.put("EVENT_DATE", new java.util.Date());

alarmData.put("MESSAGE_TEXT", your_trace_string);

(This is not a comprehensive list of what can or needs to be set).

On the substring() question: In all my years of doing router scripts I have never needed to slice a string in this manner. If you have a shoporderBO for example, then just go the the shop_order table to get the actual shop_order. Always do this as part of the single main query. And if string slicing is still needed, then use the SQL to do it too - it's easy at this level, with the advantage that you can debug your SQL long before you drop it into your script.

Former Member
0 Kudos

Thanks Stuart, I like your idea about the alarm 🐵 . I Will give that a try later today .

The SQL query im using isnt returning the shop_order_bo it is returning just the shop order but the executeQuery command returns the data as a data object and not a string. It adds information onto the front of it .

Heres the sample code

var find_shop_order=executeQuery("SELECT SHOP_ORDER.SHOP_ORDER FROM SFC INNER JOIN SHOP_ORDER ON SFC.SHOP_ORDER_BO = SHOP_ORDER.HANDLE WHERE (SFC.SFC = '" SFC"')");

print(find_shop_order)

this gives me the response

SHOP_ORDER[java.lang.String]=20100913-20

so its all the characters in front of the "20100913-20" I am trying to get rid of.

Im going to go the one query method you suggested as that reduces the overhead of running 3 seperate queries but Im trying to understand as much as I can on scripting 🐵

Thanks for all you help.

Kev

Former Member
0 Kudos

Kev

there is no other documentation on this.

The simplest way is to write a single query that returns just what you want - i.e. even to include the actual samplig decision if possible.

So, given the SFC, you can get the count of the SFCs in the same shoporder that have completed the current operation, all in one query.

I have already done a very similar router script to the one you describe (with more complexity as a certain quota of SFCs must be sampled in every order) and I use a simpler version in my router script workshop training as an example of what can be done.