Please enable Cookies to view this page. Reload
Please disable the ad blocker to support this website. Reload

How to generate a QR code for the Asset Administration Shell in Python | post-ideas.com

Start
•  Author:
account_circle
User01
  
•  Published:2023-03-10 14:59:34 (UTC±0)  •  Updated:2023-04-09 14:21:50 (UTC±0)  •   comment 0 Comments
Copyright ©. All rights reserved to the author. The author is responsible for the content presented on this page excluding the comment section.
How to generate a QR code for the Asset Administration Shell in Python
Here is a new way to generate a QR code in Python that meets the specifications of the Asset Administration Shell for the digital twin in the Industry 4.0.

A QR code to print out on paper (PDF 100 x 100 mm):

import qrcode
from PIL import Image
from reportlab.pdfgen import canvas
from reportlab.lib.units import mm, inch

content='My QR-Code'
pixel=10
qrc=qrcode.QRCode(version=3,box_size=pixel,border=0)
qrc.add_data(content)
qrc.make(fit=True)
png=qrc.make_image(fill_color='black',back_color='white')
filepath='myqrcode.png'
png.save(filepath)

pic=Image.open(filepath)
width=pic.width

modules=width/pixel
linewidth=6
w=h=modules*linewidth
linewidth1=linewidth/2
xy=5*linewidth
a=9*linewidth+w
b=6*linewidth
a1=a-b
a2=b+linewidth

p=100*mm
z=25

def add_image(filepath):
page=(p,p)
c=canvas.Canvas('myqrcode.pdf',pagesize=page)
c.drawImage(filepath,xy+z,xy+z,width=w,height=h)
c.setLineWidth(linewidth)
c.setStrokeColorRGB(0,0,0,alpha=1)
c.rect(linewidth1+z,linewidth1+z,a,a,stroke=1,fill=0)
t=c.beginPath()
t.moveTo(a+z,linewidth+z)
t.lineTo(a1+z,linewidth+z)
t.lineTo(a+z,a2+z)
c.setFillColorRGB(0,0,0,alpha=1)
c.drawPath(t,fill=1,stroke=0)
c.save()

add_image(filepath)


(Remember to use proper indentation in Python)
Document 1. Full screen
QRcode Python AssetAdministrationShell Industry40
Figure 1.
commentComments
Click here for more information.
No Comments.
language
About the Website • Privacy Notice • Terms of Service/Disclaimer/Contact
Copyright © 2022 post-ideas.com. All rights reserved.
Cookies Notice
We use cookies to ensure that we give you the best experience on our website. By continuing to visit this site you agree to our use of cookies.
Click here for more information about the use of cookies on our website.