Permalink
Browse files

Merge branch 'master' of github.com:jackdwyer/SAXS-Auto-Processor

  • Loading branch information...
2 parents 3ffe3a5 + de6a77d commit fdf79252638005e4d9ca51701c9bb65d4be60ead @jackdwyer committed May 24, 2012
Showing with 77 additions and 38 deletions.
  1. +3 −1 Core/LogLine.py
  2. +53 −26 Engine.py
  3. +2 −1 Workers/Worker.py
  4. +5 −1 Workers/WorkerBufferAverage.py
  5. +3 −1 Workers/WorkerDB.py
  6. +10 −7 Workers/WorkerEMBLmolSize.py
  7. +1 −1 config.yaml
View
@@ -58,8 +58,10 @@ def getValue(self, attribute):
if __name__ == "__main__":
+ lineNew = '<LOGLINE TimeStamp = "Wed May 23 2012 16:18:33.038" NumericTimeStamp = "119168313.038" ImageCounter = "1" exptime = "1.000000" SampleTableX = "0.000000" SampleTableY = "0.000000" Energy = "12.000001" Temperature1 = "27.170000" Temperature2 = "-270.000000" WellNumber = "1.000000" SampleType = "1" WashType = "3" SamplePhi = "1.000000" SampleOmega = "-0.085000" SampleChi = "1.400000" SampleX = "208.015625" SampleY = "-7.210000" FilePluginDestination = "FileLOGWRITER1 FileASCII1" FilePluginFileName = "/home/det/p2_det/images/data/Cycle_2012_2/Devlin_5155A/images/dark_5_0018.tif" NORD = "0" Ibs = "0" I0 = "0" It = "0" >/home/det/p2_det/images/data/Cycle_2012_2/Devlin_5155A/images/dark_5_0018.tif</LOGLINE>'
+
line = '<LOGLINE TimeStamp = "Sun Apr 01 2012 17:25:45.715" NumericTimeStamp = "114679545.715" exptime = "1" SampleTableX = "0" SampleTableY = "-0.00204353" Energy = "12" Temperature1 = "30.548" Temperature2 = "-270" WellNumber = "19" SampleType = "0" WashType = "0" FilePluginDestination = "all" FilePluginFileName = "/home/det/p2_det/images/data/Cycle_2012_1/Melton_4615/P1B7_HCL_PH3_100_NACL_0586.tif" NORD = "9" Ibs = "31460" I0 = "59688" It = "0" >/home/det/p2_det/images/data/Cycle_2012_1/Melton_4615/P1B7_HCL_PH3_100_NACL_0586.tif</LOGLINE>'
- a = LogLine(line)
+ a = LogLine(lineNew)
#print a.line
#a.getAttributes()
#print a.data
View
@@ -75,8 +75,8 @@ def __init__(self, configuration):
self.datFileLocation = "" #Properly set in setUser
- #self.logLocation = self.absoluteLocation + self.relativeLogFileLocation
- #self.datFileLocation = self.absoluteLocation + "/raw_dat/"
+ self.logLocation = self.absoluteLocation + self.relativeLogFileLocation
+ self.datFileLocation = self.absoluteLocation + "/raw_dat/"
"""
@@ -173,7 +173,11 @@ def __init__(self, configuration):
self.watchForUserChangeOver()
self.watchForImage()
- log(self.name, "All Workers ready")
+ time.sleep(0.1)
+ self.logLocation = self.absoluteLocation + self.relativeLogFileLocation
+ self.datFileLocation = self.absoluteLocation + "/raw_dat/"
+
+ log(self.name, "All Workers ready")
self.dbPush.send("test")
@@ -215,19 +219,21 @@ def watchForUserChangeOver(self):
def watchForImage(self):
epics.camonitor(self.imageTakenPV, callback=self.imageTaken)
-
+
"""
Engine Functions
- Reading log, creating log objects that can be passed around
- Getting Image/Dat File - same again creating them into objects to be thrown around
-
"""
- def imageTaken(self, **kw):
- self.readLatestLogLine()
+ def imageTaken(self, char_value, **kw):
+ print "imageTaken()"
+ self.readLatestLogLine(char_value)
- def readLatestLogLine(self):
+ def readLatestLogLine(self, image_name):
+ print "read lastest log line"
start_time = time.time()
while True:
@@ -240,9 +246,13 @@ def readLatestLogLine(self):
log(self.name, "Timeout waiting for: LOG FILE")
log(self.name, "Shutting down...")
sys.exit()
-
- self.latestLogLine = logFile.readlines()[self.index]
- self.logLines.append(LogLine.LogLine(self.latestLogLine))
+
+ self.latestLogLine = logFile.readlines()[-1]
+ tempLogLine = LogLine.LogLine(self.latestLogLine)
+ if(tempLogLine.getValue('ImageLocation') != image_name):
+ print("Image doesnt match latest line")
+ continue
+ self.logLines.append(tempLogLine)
self.index = self.index + 1
log(self.name, "LogLine read : %s" % self.latestLogLine)
self.sendLogLine(LogLine.LogLine(self.latestLogLine))
@@ -308,11 +318,12 @@ def processDatFile(self, datFile, logLine):
if (self.needBuffer):
log(self.name, "Need A Buffer")
- self.requestAverageBuffer()
- self.sendAverageBuffer(self.aveBuffer)
- self.needBuffer = False
- self.sendImage(datFile)
-
+ if (self.requestAverageBuffer()):
+ self.sendAverageBuffer(self.aveBuffer)
+ self.needBuffer = False
+ self.sendImage(datFile)
+ else:
+ log(self.name, "Request for averaged buffer failed, subtraction unable to occurr")
else:
self.sendImage(datFile)
log(self.name, "Just Image Sent")
@@ -331,12 +342,12 @@ def processDatFile(self, datFile, logLine):
if (self.needBuffer):
log(self.name, "Need A Buffer")
- self.requestAverageBuffer()
-
- self.sendAverageBuffer(self.aveBuffer)
-
- self.needBuffer = False
- self.sendImage(datFile)
+ if (self.requestAverageBuffer()):
+ self.sendAverageBuffer(self.aveBuffer)
+ self.needBuffer = False
+ self.sendImage(datFile)
+ else:
+ log(self.name, "Request for averaged buffer failed, can not subtract datfile")
else:
self.sendImage(datFile)
@@ -360,7 +371,7 @@ def getUser(self, path):
"""Splits file path, and returns only user"""
user = path.split("/")
user = filter(None, user) #needed to remove the none characters from the array
- return user[-1] #currently the user_epn is the last object in the list
+ return user[-2] #currently the user_epn is the last object in the list
def setUser(self, char_value = False, **kw):
#TODO remove this, need another way to pass user directly
@@ -395,7 +406,11 @@ def requestAverageBuffer(self):
self.aveBuffer = self.bufferRequest.recv_pyobj()
print "SELF average Buffer"
print self.aveBuffer
-
+ if (self.aveBuffer == "no_buffer"):
+ return False
+ else:
+ return True
+
def returnUser(self):
log(self.name, "Current User : " + self.user)
self.sendCommand("getUser")
@@ -449,7 +464,8 @@ def sendCommand(self, command):
self.rollingPush.send(command)
self.EMBLmolSizePush.send(command)
-
+ def testImageTaken(self):
+ self.imageTaken(epics.caget(self.imageTakenPV, as_string=True))
def sendImage(self, datFile):
self.staticPush.send("static_image")
@@ -495,12 +511,23 @@ def epicSetUser(self):
def epicImageTaken(self):
epics.caput("13SIM1:cam1:NumImages.VAL", 1, wait=True)
-
+ def getLogLoc(self):
+ print self.logLocation
+
+ def getVariables(self):
+ print "Absolute Location: ", str(self.absoluteLocation)
+ print "LogLocation: ", str(self.logLocation)
+ print "DatFile Location: ", str(self.datFileLocation)
+ print "SELF-Index: ", str(self.index)
+
+ def forceCommand(self):
+ command = raw_input("Enter Command >>")
+ self.sendCommand(command)
if __name__ == "__main__":
engine = Engine("config.yaml")
#engine.testPush()
#engine.testRequest()
- #engine.watchForChangeOver()
+ #engine.watchForChangeOver()
View
@@ -142,7 +142,8 @@ def run(self):
if (str(test) == "absolute_location"):
log(self.name, "Received Command - absolute_location")
self.absoluteLocation = self.pull.recv()
-
+ log(self.name, "Absolute Location: " + str(self.absoluteLocation))
+
if (str(test) == "getUser"):
log(self.name, "Current User : " + self.user)
@@ -130,7 +130,11 @@ def sendData(self):
self.reply.send_pyobj("REQUESTED DATA")
if (test == "request_buffer"):
log(self.name, "BufferRequested")
- self.reply.send_pyobj(self.getAverageBuffer())
+ v = self.getAverageBuffer()
+ if (v['intensities']):
+ self.reply.send_pyobj(self.getAverageBuffer())
+ else:
+ self.reply.send_pyobj("no_buffer")
View
@@ -102,7 +102,9 @@ def forceDBCreation(self, user):
raise
def buildTables(self):
- collumAttributes = ['I0', 'NumericTimeStamp', 'WashType', 'FilePluginDestination', 'TimeStamp', 'Energy', 'NORD', 'SampleType', 'It', 'SampleTableX', 'SampleTableY', 'Temperature2', 'Temperature1', 'WellNumber', 'Ibs', 'exptime', 'FilePluginFileName', 'ImageLocation']
+ collumAttributes = ['WashType', 'SampleOmega', 'FilePluginDestination', 'Temperature2', 'Temperature1', 'WellNumber', 'SamplePhi', 'NumericTimeStamp', 'I0', 'SampleY', 'SampleX', 'SampleChi', 'TimeStamp', 'SampleType', 'ImageCounter', 'Ibs', 'exptime', 'FilePluginFileName', 'Energy', 'It', 'SampleTableX', 'SampleTableY', 'NORD', 'ImageLocation']
+
+ collumAttributes_old = ['I0', 'NumericTimeStamp', 'WashType', 'FilePluginDestination', 'TimeStamp', 'Energy', 'NORD', 'SampleType', 'It', 'SampleTableX', 'SampleTableY', 'Temperature2', 'Temperature1', 'WellNumber', 'Ibs', 'exptime', 'FilePluginFileName', 'ImageLocation']
self.logTable = TableBuilder.TableBuilder(self.user, "Log", collumAttributes)
#This needs to bs fixed to support different sample types
@@ -33,26 +33,29 @@ def process(self, test):
def processDatFile(self, datFile):
- """
- process = subprocess.Popen(['autorg', '-f', 'ssv', str(datFile)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ loc = self.rootDirectory +"/" + self.user + "sub/raw_sub/" + str(datFile)
+
+ process = subprocess.Popen(['autorg', '-f', 'ssv', str(loc)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,errorOutput = process.communicate()
print output
valuePoints = output.split(" ")
rg = valuePoints[0]
- process = subprocess.Popen(['datgnom', '-r', str(rg), '-s', '12', str(datFile)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process = subprocess.Popen(['datgnom', '-r', str(rg), '-s', '12', str(loc)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,errorOutput = process.communicate()
print output
-
- process = subprocess.Popen(['datporod', 'sample_data/sum_data_4.out'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ f = datFile.split(".")
+ outFile = self.rootDirectory + self.user + "sub/raw_sub/" + str(f[0]) + ".out"
+ process = subprocess.Popen(['datporod', outFile], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,errorOutput = process.communicate()
print output
- """
+
print "in PROCESS DAT FILE FUNCTION, this needs to get correct directory"
print "THE DAT FILE IS: " + str(datFile)
f = datFile.split(".")
- print "the the enw file will be called: " + str(f[0]) + ".out"
+ print "the the enw file will be called: " + str(f[0]) + ".out"
View
@@ -9,5 +9,5 @@ RelativeLogFileLocation : "/images/livelogfile.log"
ExperimentName : "experiment1"
UserChangePV : "13PIL1:cam1:FilePath_RBV"
-ImageTakenPV : "13PIL1:cam1:NumImages_RBV"
+ImageTakenPV : "13PIL1:cam1:FullFileName_RBV"

0 comments on commit fdf7925

Please sign in to comment.