Skip to content
2 changes: 1 addition & 1 deletion 1_ElectronicFieldNotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

##mode = "DEBUG"
mode = "PRODUCTION"
EHSN_VERSION = "v2.4.1"
EHSN_VERSION = "v2.4.2"
eHSN_WINDOW_SIZE = (1100, 730)

# import wx.lib.inspection
Expand Down
17 changes: 17 additions & 0 deletions AttachBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def add(self):

def add_remove(self, evt):
if evt.GetEventObject().GetLabel() == "+":

# Only allow for one submission of an inventory management file
if self.name == "InventoryManagement" and len(self.buttonList) > 0:
info = wx.MessageDialog(self, 'Only one Inventory Management file may be included.', 'Unable to add additonal file',
wx.OK | wx.ICON_ERROR)
info.ShowModal()
return

self.columnList.append(wx.BoxSizer(wx.HORIZONTAL))
self.buttonList.append(wx.Button(self, label="-", size=self.buttonSize))
self.addrList.append(wx.TextCtrl(self, size=self.barSize))
Expand Down Expand Up @@ -149,6 +157,9 @@ def updateLabels(self):
elif self.name == "DischargeSummary" and self.addrList[id].GetValue() != "":
self.count += 1
self.labelList[id].ChangeValue(stnNum + "_" + dateVal + "_M" + str(self.count))
# There can only ever be one submission for inventory management
elif self.name == "InventoryManagement" and self.addrList[id].GetValue() != "":
self.labelList[id].ChangeValue(stnNum + "_" + dateVal + "_Inventory")

def Browse(self, evt):
id = self.browseList.index(evt.GetEventObject())
Expand All @@ -171,6 +182,12 @@ def Browse(self, evt):
wx.OK | wx.ICON_ERROR)
info.ShowModal()
return
# If the inventory management file is not a pdf, then display a warning to the user
if extension != '.md' and self.name == "InventoryManagement":
info = wx.MessageDialog(self, 'The Inventory Management File type must be Markdown.', 'Incorect file type',
wx.OK | wx.ICON_ERROR)
info.ShowModal()
return
else:

# Set the root path of the parent to be the new root path
Expand Down
96 changes: 69 additions & 27 deletions AttachmentPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from AttachFolderBox import *
from AttachPhotoBox import *
from AttachOtherBox import *
from SiteVisitOptimizationBox import *
import ntpath
import tempfile
from os import chdir
Expand Down Expand Up @@ -68,11 +69,11 @@ def InitUI(self):
self.SetSizer(self.layout)

sizerList = []
for i in range(11):
for i in range(15):
sizerList.append(wx.BoxSizer(wx.HORIZONTAL))

spaceList = []
for x in range(11):
for x in range(15):
spaceList.append(wx.StaticText(self, label=""))
note = wx.StaticText(self, label="The Field Visit Package (ZIP file) will include the eHSN xml and pdf, as well as the below attachments.")

Expand Down Expand Up @@ -101,6 +102,17 @@ def InitUI(self):
Txt8 = AttachTag("Other", "", self, size=self.tagSize)
self.attachBox8 = AttachOtherBox(self, "*", self, size=(955, 100), style=wx.SIMPLE_BORDER)

Txt9 = AttachTag("Inventory Management", "Markdown Files (.md)", self, size = self.tagSize)
self.attachBox9 = AttachBox(self, "InventoryManagement", self, size=(955, 100), style=wx.SIMPLE_BORDER)

self.largeSpacer = wx.StaticText(self, size=(955, 20), label="")
self.SVOHeader = wx.StaticText(self, label="Site Visit Optimization:", style=wx.ALIGN_CENTRE_VERTICAL)
font = wx.Font(12, wx.ROMAN, wx.FONTSTYLE_NORMAL, wx.BOLD, False)
self.SVOHeader.SetFont(font)

Txt10 = AttachTag("", "", self, size=self.tagSize)
self.attachBox10 = SVOPanel(self, "*", self, size=(955, 530), style=wx.SIMPLE_BORDER)

self.zipAddr = wx.TextCtrl(self, size=self.barSize)
self.zipAddr.SetValue(self.rootPath)
# Hide the text field
Expand Down Expand Up @@ -139,21 +151,35 @@ def InitUI(self):
sizerList[6].Add(self.attachBox6)

sizerList[7].Add(self.indent)
sizerList[7].Add(Txt7, 1, wx.EXPAND | wx.ALL, 5)
sizerList[7].Add(self.attachBox7)
sizerList[7].Add(Txt9, 1, wx.EXPAND | wx.ALL, 5)
sizerList[7].Add(self.attachBox9)

sizerList[8].Add(self.indent)
sizerList[8].Add(Txt8, 1, wx.EXPAND | wx.ALL, 5)
sizerList[8].Add(self.attachBox8)
sizerList[8].Add(Txt7, 1, wx.EXPAND | wx.ALL, 5)
sizerList[8].Add(self.attachBox7)

sizerList[9].Add(self.indent)
sizerList[9].Add(Txt8, 1, wx.EXPAND | wx.ALL, 5)
sizerList[9].Add(self.attachBox8)

sizerList[10].Add(self.noteIndent)
sizerList[10].Add(self.largeSpacer)

sizerList[9].Add(self.zipSpace)
sizerList[9].Add(self.zipper)
sizerList[11].Add(self.noteIndent)
sizerList[11].Add(self.SVOHeader)

sizerList[12].Add(self.indent)
sizerList[12].Add(Txt10, 1, wx.EXPAND | wx.ALL, 5)
sizerList[12].Add(self.attachBox10)

sizerList[13].Add(self.zipSpace)
sizerList[13].Add(self.zipper)

# Hidden text field
sizerList[10].Add(self.zipAddr)
sizerList[14].Add(self.zipAddr)

self.layout.Add(TitlePanel, 0, wx.EXPAND | wx.ALL, 3)
for i in range(11):
for i in range(15):
self.layout.Add(spaceList[i])
self.layout.Add(sizerList[i])

Expand Down Expand Up @@ -218,7 +244,7 @@ def Zip(self, evt, openSaveDialog=True):

Tag = stnNum + "_" + date + "_FV"
filePath = "c:\\temp\\eHSN\\"
boxList = [self.attachBox1, self.attachBox2, self.attachBox3, self.attachBox4, self.attachBox5, self.attachBox6, self.attachBox7, self.attachBox8]
boxList = [self.attachBox1, self.attachBox2, self.attachBox3, self.attachBox4, self.attachBox5, self.attachBox6, self.attachBox9, self.attachBox7, self.attachBox8]
pathList = []
for box in boxList:
pathList.append(box.returnPath())
Expand All @@ -241,6 +267,7 @@ def Zip(self, evt, openSaveDialog=True):
mmtPdf = self.attachBox6.returnPath()
mmtFile = self.attachBox5.returnFilePath()
mmtFolder = self.attachBox5.returnFolderPath()
inventoryFiles = self.attachBox9.returnPath()

SIT = self.attachBox7.returnSIT()
STR = self.attachBox7.returnSTR()
Expand Down Expand Up @@ -304,6 +331,14 @@ def Zip(self, evt, openSaveDialog=True):
rename = stnNum + "_" + date + "_M" + str(count) + extension
shutil.copy(mmtFile[i], dir_temp + "\\" + rename)
mmtFile[i] = dir_temp + "\\" + rename
# Inventory management markdown files
for i in range(len(inventoryFiles)):
if valid(inventoryFiles[i]):
name, extension = os.path.splitext(inventoryFiles[i])
# Do not include the count in the file name
rename = stnNum + "_" + date + "_Inventory" + extension
shutil.copy(inventoryFiles[i], dir_temp + "\\" + rename)
inventoryFiles[i] = dir_temp + "\\" + rename
# Photos and drawings
count = 0
for i in range(len(SIT)):
Expand Down Expand Up @@ -424,6 +459,9 @@ def Zip(self, evt, openSaveDialog=True):
for path in mmtFile:
if valid(path):
zipfile.write(path, Tag + "\\" + ntpath.basename(path))
for path in inventoryFiles:
if valid(path):
zipfile.write(path, Tag + "\\" + ntpath.basename(path))

# Discharge measurement folders
count = 0
Expand Down Expand Up @@ -570,22 +608,26 @@ def Zip(self, evt, openSaveDialog=True):
if valid(path):
zipfile.write(path, Tag + "\\" + ntpath.basename(path))

# Adding the details from the Inventory Management tab
# This generates a markdown file and returns the filepath
# Running this three times deliberately as some changes are not caught in initial call
inventory_text_filepath = self.parent.inventoryManagement.printChangesOutput()
inventory_text_filepath = self.parent.inventoryManagement.printChangesOutput()
inventory_text_filepath = self.parent.inventoryManagement.printChangesOutput()

if inventory_text_filepath != "":

# Write the file to the zip
if valid(inventory_text_filepath):
zipfile.write(inventory_text_filepath, Tag + "\\" + stnNum + "_" + date + "_Inventory.md")

# Delete the file once it is in the zip
if os.path.exists(inventory_text_filepath):
os.remove(inventory_text_filepath)
# Only add the inventory management file if the user has not added their own
inventory_pathname = Tag + "/" + stnNum + "_" + date + "_Inventory.md"
if not inventory_pathname in zipfile.namelist():

# Adding the details from the Inventory Management tab
# This generates a markdown file and returns the filepath
# Running this three times deliberately as some changes are not caught in initial call
inventory_text_filepath = self.parent.inventoryManagement.printChangesOutput()
inventory_text_filepath = self.parent.inventoryManagement.printChangesOutput()
inventory_text_filepath = self.parent.inventoryManagement.printChangesOutput()

if inventory_text_filepath != "":

# Write the file to the zip
if valid(inventory_text_filepath):
zipfile.write(inventory_text_filepath, Tag + "\\" + stnNum + "_" + date + "_Inventory.md")

# Delete the file once it is in the zip
if os.path.exists(inventory_text_filepath):
os.remove(inventory_text_filepath)

zipfile.close()
if openSaveDialog:
Expand Down
10 changes: 10 additions & 0 deletions ElectronicFieldNotesGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,11 @@ def OnFileSave(self, e):

self.manager.ExportAsXML(self.fullname, None)
print("File saved")

# Export the markdown file from inventory management
savedFilePath = os.path.dirname(os.path.abspath(self.fullname))
self.inventoryManagement.exportChangesOutput(savedFilePath)

return True
return False

Expand Down Expand Up @@ -1050,6 +1055,11 @@ def OnFileSaveAs(self, evt):
self.fullname = path
# self.ResetSaveAsIni(path)
print("XML file saved")

# Export the markdown file from inventory management
savedFilePath = os.path.dirname(os.path.abspath(self.fullname))
self.inventoryManagement.exportChangesOutput(savedFilePath)

return True


Expand Down
10 changes: 8 additions & 2 deletions IngestQRevIntMSManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ def GetFrequencyUnit(filePath):
return GetRoot(filePath).find('Instrument').find('Frequency').attrib['unitsCode']

def GetADCPDepth(filePath):
return GetRoot(filePath).find('VerticalDetails/Vertical/Processing/Depth/ADCPDepth').text
try:
return GetRoot(filePath).find('VerticalDetails/Vertical/Processing/Depth/ADCPDepth').text
except:
return ""

def GetDiagTest(filePath):
return GetRoot(filePath).find('QA').find('DiagnosticTestResult').text

def GetMagDeclination(filePath):
return GetRoot(filePath).find('VerticalDetails/Vertical/Processing/Navigation/MagneticVariation').text
try:
return GetRoot(filePath).find('VerticalDetails/Vertical/Processing/Navigation/MagneticVariation').text
except:
return ""


#Calculate the mean time
Expand Down
4 changes: 3 additions & 1 deletion IngestQRevManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def GetDate(filePath):

def GetQRevVersion(filePath):
QRevVer = GetRoot(filePath).attrib['QRevVersion']
return float(QRevVer[(len(QRevVer) - 5):])
versionFull = QRevVer.split()[1]
values = versionFull.split('.')
return float(values[0] + '.' + values[1])

#Summary
def GetStartTime(filePath):
Expand Down
4 changes: 2 additions & 2 deletions InstrumentDeploymentInfoPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, mode, *args, **kwargs):
self.flowAngleLbl = "Flow Angle"
self.flowAngleList = ["", "Perpendicular", "Varied"]
self.coEffLbl = "Coefficient"
self.coefficientList = ["","-1", "1", "0.88"]
self.coefficientList = ["","-1", "1", "0.88", "0.88+1.00"]
self.methodLbl = "Method"
self.methodList = ["", "0.6", "0.2/0.8", "0.6+0.2/0.8", "0.6+0.5", "0.5", "0.5+0.2/0.8", "Surface", "0.2/0.6/0.8", "0.2/0.5/0.8", "ADCP"]
self.locatedLbl = "Located"
Expand Down Expand Up @@ -505,7 +505,7 @@ def InitUI(self):
self.coEffCtrl = MyComboBox(self.midsectionMethodInfoPanel, choices=self.coefficientList, style=wx.CB_DROPDOWN, size=(180, -1))
# self.coEffCtrl = wx.TextCtrl(self.midsectionMethodInfoPanel, style=wx.TE_PROCESS_ENTER, size=(180, -1))
# self.coEffCtrl.Bind(wx.EVT_TEXT, NumberControl.FloatNumberControl)
self.coEffCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round2)
# self.coEffCtrl.Bind(wx.EVT_KILL_FOCUS, NumberControl.Round2)
self.coEffCtrl.Bind(wx.EVT_TEXT, self.OnChangeResetBGColour)
mmiHorizontalSizer1.Add(self.numOfPanelsTxt, 0, wx.EXPAND|wx.TOP|wx.RIGHT, 5)
mmiHorizontalSizer1.Add(self.numOfPanelsScroll, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
Expand Down
Loading