PEP 8 — Style Guide for Python Code

This document gives coding conventions for the Python code comprising the standard library in the main Python distribution.

This document and PEP 257 (Docstring Conventions) were adapted from Guido’s original Python Style Guide essay, with some additions from Barry’s style guide [2].

http://www.python.org/dev/peps/pep-0008

Is it easy to create and maintain custom user interfaces in Scorpion?

Read more Scorpion Online Help

Read more Scorpion Online Help

It has always been easy to create custom interface pages in Scorpion. They can be developed as web pages, activeX control, .Net objects or as Data Input pages.

When we invented the The Data Input page concept we did not understand how important this was for Scorpion Vision.

The basic idea was to replace the need for custom html or .Net pages that is easy to embed in the Scorpion Application. It is used in almost all Scorpion Vision Systems.

The main purpose is to let the profile builder to quickly expose selected parameters to be configured by the operator or the user of the Scorpion Vision profile – it is easy and extremely powerful feature. With data input concept the pages are built on site and often maintained by the operator. This means that they are up to date and defined by the people using it.

An input page consists of named groups or sections. In each group a list of editable parameters is contained. A group or an item can be copied between pages and profiles.

The Data Input concept is also added to the generic BaseTool for creation custom user tool and the ToolBox. This means that the user interface is moved out into the tool where it really belongs. In this way it is possible to copy the tool including the data input gui between profiles.

Below an input page is added to the Settings tab – password protected with the operator password.

PythonScript – Hint

When working with Python Scripts in Scorpion  adding the following snippet will produce a nice header in the console windows for a script tool.

print GetCurSource()
print ‘-‘*20   # prints 20 –

Output:

CreateOuput
--------------------------
zxzx
zxzx


How to communicate with a PLC?

The following questions must be asked before you select the method for PLC communication:

  • HW Protocol – RS232, Profibus, DeviceNet, io or  tcp/ip?
  • SW Protocol – custom, OPC or vendor protocol

In Scorpion there are a multitude of communication methods built-in and most of this is done without too much work. The most important tool for communication is the built-in python framework and the built in tdvcmdprotocol supporting tcp/ip and rs-232.

RS-232 Communication

There are two choices: Use the built-in RS232TDVCmdProtocol. This is very good no programming option.

Read more…

The other option with RS-232 is to write your own serialport decoder in Python. Read more…

Profibus and DeviceNet

This is a “Siemens” protocol. This is supported using OPC. To use this option requires that you buy interface cards from the bus vendors. All these solutions provide an OPC-Server.  Scorpion provides provide general client access to these servers.

Read more…

Digital IO

There are many ways of doing this. A popular approach is to interface with the Advantech products with the products Adam-6060 or PCI-1370. The adam-6060 provides io over ethernet and pci-1370 provides fast io based on an pci-card.

TCP-IP Communication

InternetMessenger is one choice.  Can be difficult use – it require that this protocol must be implemented on the PLC.

Read more…

The best choice is normally a custom tcp/ip protocol implemented in python.

Read more…

 

 

 

How to retrieve image size from python?

import arr

img = GetImageMatr('Image')
ROWS,COLS = img.dim()
print 'image size ',ROWS,COLS

How to activate Live Video?

The Scorpion System Registers contains a property LiveVideo

* SetBoolValue(‘System.LiveVideo’, 1 )

will activate Live Video

Deactivating Live Video is left as an exercise to the user

Scorpion 8 fails to start

After installing Scorpion 8 the following error message is received:

* The application failed to initialize properly or .net is not working properly

Try the new Scorpion 8 Extentions Installer to fix the problem.

This error message is most probably due to missing/old Microsoft Runtime libraries incompatible with Scorpion 8 and python 2.6.

To correct the problem try the following in sequence :

  1. Install Microsoft Vs-2005 sp1  Runtimes
  2. Install Python 2.6.x
    • Link to download python 2.6 installation guide  here
  3. Read and apply the Scorpion 8 Installation Tutorial – click here to download…
If everything fails send an e-mail to support@tordivel.no

The error message is most likely to be received when upgrading older XP machines.

Final checklist:

  • Deinstall previous Scorpion 8 versions
    • Check software version in Control Panel
    • The reinstall the lastest Scorpion Vision 8
  • Deinstall and reinstall Python 2.6.x
    • This can fix a not working .net in python