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

Can you access ODBC databases from Scorpion?

Yes we can 🙂

The pyODBC module provides an elegant way to access databases.

More information: http://code.google.com/p/pyodbc/

Getting started : http://code.google.com/p/pyodbc/wiki/GettingStarted

What is Scorpion VisionX?

The VisionX is a complete software component for adding image processing and camera support to any windows application.
The component contains the following elements:
  • Scorpion 2D and 3D Image Processing
  • Interface to Web, Network, Area and Line Scan cameras over USB, GigE, CameraLink and Firewire
  • Camera Viewer with zoom, measurement, save and overlay graphics
  • Python Scripting Engine

More information:

With the release of Scorpion 8 the following is added to VisionX:

  • A new low cost entry level for 1D and 2D barcodes decoding
    • list price  starts at 375 euro includes image capture
  • OpenCV version starts at 375 euro listprice
    • A complete vision system including image capture

VisionX is a runtime component with a standard SDK purchace requirement.

Cannot locate NumPy or other python modules?

Verify that the PythonPath is set to site-packages.

The default PyhtonPath is:   c:\python26\lib\site-packages

The settings in located in the Control Panel.

PythonPath set to locate SitePackages