Hi everyone, I have facing some issues with the timer script in Vision... On our side, we had a timer script for generating glass files... These files contain the produced glass file details and it is in CSV format. Sometimes it will work well, but sometimes it doesn't work... At that time we had to face some issues... We had put the script in TRY and Except function. So, weed to identify when the timer script has worked and not working. when it; 's not working we should trigger a mail... So already created a mail handler for this one and tested.. But don't know how to find if the script worked or not... I'll be given the script below...
from project.ftps import ImplicitFTPS
import ftplib
import traceback
Start_Time = system.date.now()
Start_Time_Tag = system.tag.writeBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/Script_Start_Time", Start_Time)
logger = system.util.getLogger('CO02_snapshot')
lineSpeed = round(system.tag.read("[c02cbsv3]c2TOPServer/32_hegla/actProcessSpeed").value,2)
#if (lineSpeed>=0.5):
try :
filedate= system.tag.read('[System]Gateway/CurrentDateTime').value
filedate= system.date.format(filedate, 'yyyyMMddHHmmss')
fileloc = "/DATA/CN_CO2/snapshot_files/"
filename = filedate + "_snapshot_15s.csv"
finalPath = fileloc + filename
snapShotHead = ["WriteTime","Description","Environment","actProcessSpeed","nomProcessSpeed","rLastGAP","currentGlassId","currentBatchID","currentSourceOfLoad","currentGlassThickness","currentGlassType",
"currentGlassColorCode","currentGlassLength","currentGlassWidth","coverName","powerSupplyId","supplyType","supply1Status","targetMaterial1ID","targetMaterial2ID","actTarget1KWH","actTarget2KWH",
"actVoltage","spVoltage","actCurrent","actPower","spPower","actArcRate1","actArcRate2","spPvcValue","supplyMode","actMainGas1","spMainGas1","actMainGas2","spMainGas2","actMainGas3","spMainGas3",
"actMainGas4","spMainGas4","actMainGas5","spMainGas5","trimGas1Status","trimGas2Status","trimGas3Status","trimGas4Status","trimGas5Status","trimGas6Status","trimGas7Status","trimGas8Status","trimGas9Status",
"trimGas10Status","trimGas11Status","actTrimGas1","spTrimGas1","actTrimGas2","spTrimGas2","actTrimGas3","spTrimGas3","actTrimGas4","spTrimGas4","actTrimGas5","spTrimGas5","actTrimGas6",
"spTrimGas6","actTrimGas7","spTrimGas7","actTrimGas8","spTrimGas8","actTrimGas9","spTrimGas9","actTrimGas10","spTrimGas10","actTrimGas11","spTrimGas11","actVacuumPressure","gasSelection","nomGasSegment", "RGAHydrogen", "RGAHelium", "RGAAtomicNitrogen", "RGAAtomicOxygen", "RGAWater", "RGANitrogen", "RGAOxygen", "RGAArgonIsotope", "RGAArgon", "RGACarbondioxide"]
rowDatas = []
for i in range(1,81):
compRow = generalFunc.snapShotData(i,snapShotHead,filedate)
rowDatas.append(compRow)
snapShotDataset = system.dataset.toDataSet(snapShotHead,rowDatas)
csvfiledata = system.dataset.toCSV(snapShotDataset)
csvfiledata = csvfiledata.replace('"','')
csvfiledata = csvfiledata.replace(',',';')
csvfiledata = csvfiledata.replace('"True"', '"1"')
csvfiledata = csvfiledata.replace('"False"', '"0"')
system.file.writeFile(finalPath,csvfiledata)
#SnapShot File Count Created in Ignition Server
fileCreated = int(system.tag.read("[c02cbsv3]c2TOPServer/15_GatewayScript_Status/SnapshotFile_Created").value)
fileInc = fileCreated + 1
system.tag.write("[c02cbsv3]c2TOPServer/15_GatewayScript_Status/SnapshotFile_Created",fileInc)
End_Time = system.date.now()
End_Time_Tag = system.tag.writeBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/Script_End_Time", End_Time)
system.tag.writeBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/SnapShot_MailTrigger", 0)
system.tag.writeBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/Snapshot_Script_Status",1)
# system.tag.writeBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/Error_File_Count",0)
# system.util.getLogger(logger).info(str("Snapshot file created succesfully"))
logger.info('snapshot generated')
except Exception as e :
Nc_File = system.tag.readBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/Error_File_Count")[0].value
Nc_Count_inc = Nc_File + 1
system.tag.writeBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/Error_File_Count",Nc_Count_inc)
# system.tag.writeBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/SnapShot_MailTrigger", 1)
# system.tag.writeBlocking("[c02cbsv3]c2TOPServer/testingTags/Gateway_Mail_Tags/Snapshot_Script_Status",0)
logger.info(str("Snapshot not Created"))
# system.util.getLogger(log_name).info(traceback.format_exc())
# pass
Thanks,
Muniyandi