Browse Source

refactored,improved design

add-license-1
Yiğit Çolakoğlu 7 years ago
parent
commit
e057ef0b39
4 changed files with 91 additions and 53 deletions
  1. +30
    -16
      Barcode_Reader_Python/.idea/workspace.xml
  2. +59
    -35
      Barcode_Reader_Python/database_append.py
  3. +0
    -0
      Barcode_Reader_Python/database_read.py
  4. +2
    -2
      Barcode_Reader_Python/main.py

+ 30
- 16
Barcode_Reader_Python/.idea/workspace.xml View File

@ -2,11 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="7b5ef56c-2d3e-44d9-be69-b414f166f99b" name="Default" comment="">
<change afterPath="$PROJECT_DIR$/database_append.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database_actions.py" beforeDir="false" afterPath="$PROJECT_DIR$/database_actions.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/move.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/database_append.py" beforeDir="false" afterPath="$PROJECT_DIR$/database_append.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -24,7 +21,7 @@
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$main.coverage" NAME="main Coverage Results" MODIFIED="1529672838644" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$Unnamed.coverage" NAME="raspberry_live Coverage Results" MODIFIED="1529543452123" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$database_actions.coverage" NAME="database_actions Coverage Results" MODIFIED="1529665501332" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$database_append.coverage" NAME="database_append Coverage Results" MODIFIED="1529674944251" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$database_append.coverage" NAME="database_append Coverage Results" MODIFIED="1529689670654" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
@ -52,8 +49,8 @@
<file leaf-file-name="database_append.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/database_append.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="167">
<caret line="33" column="44" selection-start-line="33" selection-start-column="44" selection-end-line="33" selection-end-column="44" />
<state relative-caret-position="340">
<caret line="20" column="1" lean-forward="true" selection-start-line="20" selection-start-column="1" selection-end-line="20" selection-end-column="1" />
</state>
</provider>
</entry>
@ -86,6 +83,11 @@
</findStrings>
</component>
<component name="Git.Settings">
<option name="PREVIOUS_COMMIT_AUTHORS">
<list>
<option value="Yiğit Çolakoğlu &lt;yigitcolakoglu@hotmail.com&gt;" />
</list>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="IdeDocumentHistory">
@ -144,7 +146,7 @@
<property name="last_opened_file_path" value="$PROJECT_DIR$/run.py" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="preferences.sourceCode.Python" />
<property name="settings.editor.selected.configurable" value="preferences.keymap" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
@ -158,7 +160,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Python.database_append">
<component name="RunManager" selected="Python.database_actions">
<configuration name="RUN" type="PythonConfigurationType" factoryName="Python">
<module name="Barcode_Reader_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -191,7 +193,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/database_actions.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/database_read.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@ -322,26 +324,34 @@
<option name="presentableId" value="Default" />
<updated>1529543214918</updated>
</task>
<task id="LOCAL-00001" summary="completed the algorithm">
<created>1529689633554</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1529689633554</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="ToolWindowManager">
<frame x="0" y="24" width="1920" height="1030" extended-state="6" />
<editor active="true" />
<layout>
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Messages" />
<window_info anchor="bottom" id="Event Log" order="7" sideWeight="0.5007587" side_tool="true" weight="0.4638365" />
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="7" />
<window_info anchor="bottom" id="Python Console" order="7" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49924126" visible="true" weight="0.28426966" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49924126" weight="0.28426966" />
<window_info anchor="bottom" id="Terminal" order="7" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.19070514" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.19070514" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="right" id="Database" order="3" />
<window_info anchor="right" id="SciView" order="3" weight="0.32928678" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4033708" />
<window_info anchor="bottom" id="Debug" order="3" visible="true" weight="0.4033708" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.24962063" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
@ -380,6 +390,10 @@
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="completed the algorithm" />
<option name="LAST_COMMIT_MESSAGE" value="completed the algorithm" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="4" />
@ -477,8 +491,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/database_append.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="167">
<caret line="33" column="44" selection-start-line="33" selection-start-column="44" selection-end-line="33" selection-end-column="44" />
<state relative-caret-position="340">
<caret line="20" column="1" lean-forward="true" selection-start-line="20" selection-start-column="1" selection-end-line="20" selection-end-column="1" />
</state>
</provider>
</entry>


+ 59
- 35
Barcode_Reader_Python/database_append.py View File

@ -1,9 +1,9 @@
import pyrebase
config = {
"apiKey": "AIzaSyD3bXRjLxEAVOKtj8hpjO4iI3Nn32F7agU",
"authDomain": "foodcloud-f6eb1.firebaseapp.com",
"databaseURL": "https://foodcloud-f6eb1.firebaseio.com/",
"apiKey": "AIzaSyD3bXRjLxEAVOKtj8hpjO4iI3Nn32F7agU",
"authDomain": "foodcloud-f6eb1.firebaseapp.com",
"databaseURL": "https://foodcloud-f6eb1.firebaseio.com/",
"storageBucket": "foodcloud-f6eb1.appspot.com"
}
@ -15,38 +15,62 @@ user = auth.sign_in_with_email_and_password('yigitcolakohlu@gmail.com', 'FoodWro
db = firebase.database()
data_format_prod = {'Prod_Name': None, 'BBD': None, 'Nutrients': [], 'Calories': 0, 'Allergens': [],
'Problematic': False, 'Process': None, 'ED': None}
data_format_proc = {'Harvested': {'Date': '', 'Location': '', 'Product': ''},
'Transport1': {'Duration': 0, 'Moved to,from': '-', 'Condition': True, 'Stopped': False},
'Process': {'Location': '', 'Processes': ''},
'Transport2': {'Duration': 0, 'Moved to,from': '-', 'Condition': 0, 'Stopped': False},
'Packaging': {'Location': '', 'Material': '', 'Cancerogen': True}}
data_1_prod = {'Prod_Name': "Milk", 'BBD': "24.08.2018", 'Nutrients': ['Protein', 'Fat', 'Lactose', 'Glucose'],
'Calories': 120, 'Cooked': False, 'Allergens': ['Lactose'], 'Problematic': False,
'Process': 'Pastorized'}
data_2_prod = {'Prod_Name': "Chocolate", 'BBD': "28.01.2019", 'Nutrients': ['Lactose', 'Glucose', 'Cocoa'],
'Calories': 180, 'Cooked': False, 'Allergens': [""], 'Problematic': False, 'Process': ''}
data_1_proc = {'Harvested': {'Date': '18.08.2018', 'Location': 'Larson Family',
'Product': 'Raw Milk'},
'Transport1': {'Duration': 9, 'Moved to,from': 'Larson Family-McCarty Family Farms', 'Condition': True,
'Stopped': True}, 'Process': {'Location': 'McCarty Family Farms',
'Processes': 'Reverse Osmosis,Nanofiltration,Ultrafiltration,Microfiltration'},
'Transport2': {'Duration': 13, 'Moved to,from': 'McCarty Family Farms-JJX Packaging', 'Condition': True,
'Stopped': True},
'Packaging': {'Location': 'JJX Packaging', 'Material': 'Carton', 'Cancerogen': False}}
data_2_proc = {'Harvested': {'Date': '27.01.2018', 'Location': 'India',
'Product': 'Cocoa'},
'Transport1': {'Duration': 71, 'Moved to,from': 'India-Nestle ', 'Condition': True, 'Stopped': True},
'Process': {'Location': 'Nestle', 'Processes': 'Roasting,Pulp,Conching,Moulding'},
'Transport2': {'Duration': 4, 'Moved to,from': 'Nestle-Ulma Packaging', 'Condition': True,
'Stopped': False},
'Packaging': {'Location': 'Ulma Packaging', 'Material': 'Foil', 'Cancerogen': False}}
data_format_prod = {
'Prod_Name': None, 'BBD': None, 'Nutrients': [], 'Calories': 0, 'Allergens': [],
'Problematic': False, 'Process': None, 'ED': None
}
data_format_proc = {
'Harvested': {'Date': '', 'Location': '', 'Product': ''},
'Transport1': {'Duration': 0, 'Moved to,from': '-', 'Condition': True, 'Stopped': False},
'Process': {'Location': '', 'Processes': ''},
'Transport2': {'Duration': 0, 'Moved to,from': '-', 'Condition': 0, 'Stopped': False},
'Packaging': {'Location': '', 'Material': '', 'Cancerogen': True}
}
data_1_prod = {
'Prod_Name': "Milk", 'BBD': "24.08.2018", 'Nutrients': ['Protein', 'Fat', 'Lactose', 'Glucose'],
'Calories': 120, 'Cooked': False, 'Allergens': ['Lactose'], 'Problematic': False,
'Process': 'Pastorized'
}
data_2_prod = {
'Prod_Name': "Chocolate", 'BBD': "28.01.2019", 'Nutrients': ['Lactose', 'Glucose', 'Cocoa'],
'Calories': 180, 'Cooked': False, 'Allergens': [""], 'Problematic': False, 'Process': ''
}
data_1_proc = {
'Harvested': {
'Date': '18.08.2018', 'Location': 'Larson Family',
'Product': 'Raw Milk'
},
'Transport1': {
'Duration': 9, 'Moved to,from': 'Larson Family-McCarty Family Farms', 'Condition': True,
'Stopped': True
}, 'Process': {
'Location': 'McCarty Family Farms',
'Processes': 'Reverse Osmosis,Nanofiltration,Ultrafiltration,Microfiltration'
},
'Transport2': {
'Duration': 13, 'Moved to,from': 'McCarty Family Farms-JJX Packaging', 'Condition': True,
'Stopped': True
},
'Packaging': {'Location': 'JJX Packaging', 'Material': 'Carton', 'Cancerogen': False}
}
data_2_proc = {
'Harvested': {
'Date': '27.01.2018', 'Location': 'India',
'Product': 'Cocoa'
},
'Transport1': {'Duration': 71, 'Moved to,from': 'India-Nestle ', 'Condition': True, 'Stopped': True},
'Process': {'Location': 'Nestle', 'Processes': 'Roasting,Pulp,Conching,Moulding'},
'Transport2': {
'Duration': 4, 'Moved to,from': 'Nestle-Ulma Packaging', 'Condition': True,
'Stopped': False
},
'Packaging': {'Location': 'Ulma Packaging', 'Material': 'Foil', 'Cancerogen': False}
}
Products = [data_1_prod, data_2_prod]
Processes = [data_1_proc, data_2_proc]


Barcode_Reader_Python/database_actions.py → Barcode_Reader_Python/database_read.py View File


+ 2
- 2
Barcode_Reader_Python/main.py View File

@ -3,7 +3,7 @@ from pyzbar import pyzbar
import imutils
import time
import cv2
import database_actions
import database_read
import datetime
import generate_moves
import serial
@ -72,7 +72,7 @@ while reps<1:
0.5, (0, 0, 255), 2)
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData))
dates.append(database_actions.getDate(barcodeData))
dates.append(database_read.getDate(barcodeData))
reps += 1
arduino.write("1")


Loading…
Cancel
Save