ret = system.tag.writeBlocking([
FolderPath+"SO",
FolderPath+"OpenType",
FolderPath+"Product",
#FolderPath+"WidthLL",
#FolderPath+"HeightHH",
#FolderPath+"FireClass",
#FolderPath+"MaterialFinishing",
#FolderPath+"RivetsNumber",
#FolderPath+"DestinationRoller",
#FolderPath+"PanelCounter",
],
[
r["SO"],
r["OpenType"],
r["Product"],
#r["WidthLL"],
#r["HeightHH"],
#r["FireClass"],
#r["MaterialFinishing"],
#r["RivetsNumber"],
#r["DestinationRoller"],
#r["PanelCounter"],
])
PLC is siemens 1500, whit opcua server enabled.
When i use the WriteBlock it give me Good for all the entry of the array, but it actually write only the last one.
Am I missing something?
Thanks for your time.
Full Script ------------
def Go(PO, PanelSide, PanelID, FolderPath):
#converto il valore utilizzato dal PLC
PanelSide = "DX" if PanelSide == 2 else "SX"
r = GetData(PO, PanelSide, PanelID)
r = system.dataset.toPyDataSet(r)
if not r :
print "nessuna riga trovata"
exit()
if r.getRowCount() > 1 :
print "error numero righe"
exit()
#se non ci sono errori prendo la prima riga
r = Conversions(r)
r = r[0]
#compongo la path per i dati
FolderPath = FolderPath + "/Data/"
ret = system.tag.writeBlocking([
FolderPath+"SO",
FolderPath+"OpenType",
FolderPath+"Product",
#FolderPath+"WidthLL",
#FolderPath+"HeightHH",
#FolderPath+"FireClass",
#FolderPath+"MaterialFinishing",
#FolderPath+"RivetsNumber",
#FolderPath+"DestinationRoller",
#FolderPath+"PanelCounter",
],
[
r["SO"],
r["OpenType"],
r["Product"],
#r["WidthLL"],
#r["HeightHH"],
#r["FireClass"],
#r["MaterialFinishing"],
#r["RivetsNumber"],
#r["DestinationRoller"],
#r["PanelCounter"],
])
print r["Product"]
print r["SO"]
print r["OpenType"]
#------------------------------------------------------------------------------
def GetData(PO, PanelSide, PanelID):
p = {"PO":PO, "PanelSide":PanelSide,"PanelID":PanelID}
r = system.db.runNamedQuery("NuovaMatricola",p)
return r
#------------------------------------------------------------------------------
#conversioni dovute a dati scritti diversamente su PLC
def Conversions(r):
openType = -1
if r[0]["OpenType"] == "1C" : openType = 1
if r[0]["OpenType"] == "2L" : openType = 2
if r[0]["OpenType"] == "3R" : openType = 3
r = system.dataset.setValue(r,0,"OpenType",openType)
r = system.dataset.toPyDataSet(r)
destinationRoller = -1
if r[0]["DestinationRoller"] == "P20" : destinationRoller = 0
if r[0]["DestinationRoller"] == "P50" : destinationRoller = 1
r = system.dataset.setValue(r,0,"DestinationRoller",destinationRoller)
print destinationRoller
r = system.dataset.toPyDataSet(r)
return r
#------------------------------------------------------------------------------