Browse Source

completed the algorithm

add-license-1
Yiğit Çolakoğlu 7 years ago
parent
commit
c824fb1a57
5 changed files with 128 additions and 67 deletions
  1. +67
    -55
      Barcode_Reader_Python/.idea/workspace.xml
  2. +1
    -8
      Barcode_Reader_Python/database_actions.py
  3. +58
    -0
      Barcode_Reader_Python/database_append.py
  4. +2
    -3
      Barcode_Reader_Python/main.py
  5. +0
    -1
      Barcode_Reader_Python/move.py

+ 67
- 55
Barcode_Reader_Python/.idea/workspace.xml View File

@ -2,11 +2,11 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="7b5ef56c-2d3e-44d9-be69-b414f166f99b" name="Default" comment="">
<change afterPath="$PROJECT_DIR$/.idea/codeStyles/codeStyleConfig.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/move.py" afterDir="false" />
<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$/generate_moves.py" beforeDir="false" afterPath="$PROJECT_DIR$/generate_moves.py" 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" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -24,14 +24,15 @@
<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$" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="main.py" pinned="false" current-in-tab="true">
<file leaf-file-name="main.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="425">
<caret line="59" column="15" lean-forward="true" selection-start-line="59" selection-start-column="15" selection-end-line="59" selection-end-column="15" />
<state relative-caret-position="538">
<caret line="88" column="1" selection-start-line="88" selection-start-column="1" selection-end-line="88" selection-end-column="1" />
<folding>
<element signature="e#0#37#0" expanded="true" />
</folding>
@ -39,34 +40,29 @@
</provider>
</entry>
</file>
<file leaf-file-name="move.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/move.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file leaf-file-name="generate_moves.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/generate_moves.py">
<file leaf-file-name="database_actions.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/database_actions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1875">
<caret line="125" column="20" selection-start-line="125" selection-start-column="20" selection-end-line="125" selection-end-column="20" />
<state relative-caret-position="450">
<caret line="25" selection-start-line="25" selection-end-line="25" selection-end-column="49" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="sort_date.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/sort_date.py">
<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="1770">
<caret line="118" selection-start-line="118" selection-end-line="118" />
<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>
</provider>
</entry>
</file>
<file leaf-file-name="database_actions.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/database_actions.py">
<file leaf-file-name="pydevd.py" pinned="false" current-in-tab="false">
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/pydevd.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<caret line="8" selection-start-line="8" selection-end-line="8" />
<state relative-caret-position="169">
<caret line="1067" selection-start-line="1067" selection-end-line="1067" />
</state>
</provider>
</entry>
@ -102,6 +98,8 @@
<option value="$PROJECT_DIR$/generate_moves.py" />
<option value="$PROJECT_DIR$/move.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/database_actions.py" />
<option value="$PROJECT_DIR$/database_append.py" />
</list>
</option>
</component>
@ -160,7 +158,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Python.main">
<component name="RunManager" selected="Python.database_append">
<configuration name="RUN" type="PythonConfigurationType" factoryName="Python">
<module name="Barcode_Reader_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -199,7 +197,7 @@
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<configuration name="generate_moves" type="PythonConfigurationType" factoryName="Python" temporary="true">
<configuration name="database_append" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="Barcode_Reader_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -212,13 +210,13 @@
<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$/generate_moves.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/database_append.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
<configuration name="generate_moves" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="Barcode_Reader_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -231,13 +229,13 @@
<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$/main.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/generate_moves.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<configuration name="move" type="PythonConfigurationType" factoryName="Python" temporary="true">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="Barcode_Reader_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -250,45 +248,45 @@
<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$/move.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<configuration name="raspberry_live" type="PythonConfigurationType" factoryName="Python">
<configuration name="move" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="Barcode_Reader_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="/usr/bin/python2.7" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="false" />
<option name="IS_MODULE_SDK" value="true" />
<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$/raspberry_zbar.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/move.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
</configuration>
<configuration name="sort_date" type="PythonConfigurationType" factoryName="Python" temporary="true">
<configuration name="raspberry_live" type="PythonConfigurationType" factoryName="Python">
<module name="Barcode_Reader_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="SDK_HOME" value="/usr/bin/python2.7" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="IS_MODULE_SDK" value="false" />
<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$/sort_date.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/raspberry_zbar.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@ -298,18 +296,18 @@
<item itemvalue="Python.raspberry_live" />
<item itemvalue="Python.RUN" />
<item itemvalue="Python.main" />
<item itemvalue="Python.sort_date" />
<item itemvalue="Python.generate_moves" />
<item itemvalue="Python.database_actions" />
<item itemvalue="Python.move" />
<item itemvalue="Python.database_append" />
</list>
<recent_temporary>
<list>
<item itemvalue="Python.database_append" />
<item itemvalue="Python.main" />
<item itemvalue="Python.move" />
<item itemvalue="Python.generate_moves" />
<item itemvalue="Python.database_actions" />
<item itemvalue="Python.sort_date" />
</list>
</recent_temporary>
</component>
@ -335,7 +333,7 @@
<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.19213483" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49924126" visible="true" 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 anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
@ -343,7 +341,7 @@
<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.39775282" />
<window_info anchor="bottom" id="Debug" order="3" 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" />
@ -436,13 +434,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database_actions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<caret line="8" selection-start-line="8" selection-end-line="8" />
</state>
</provider>
</entry>
<entry file="file:///usr/lib/python2.7/dist-packages/serial/serialposix.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="214">
@ -450,25 +441,46 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/move.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/generate_moves.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1875">
<state relative-caret-position="483">
<caret line="125" column="20" selection-start-line="125" selection-start-column="20" selection-end-line="125" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/move.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="425">
<caret line="59" column="15" lean-forward="true" selection-start-line="59" selection-start-column="15" selection-end-line="59" selection-end-column="15" />
<state relative-caret-position="538">
<caret line="88" column="1" selection-start-line="88" selection-start-column="1" selection-end-line="88" selection-end-column="1" />
<folding>
<element signature="e#0#37#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database_actions.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="25" selection-start-line="25" selection-end-line="25" selection-end-column="49" />
</state>
</provider>
</entry>
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/pydevd.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="169">
<caret line="1067" selection-start-line="1067" selection-end-line="1067" />
</state>
</provider>
</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>
</provider>
</entry>
</component>
</project>

+ 1
- 8
Barcode_Reader_Python/database_actions.py View File

@ -11,17 +11,10 @@ firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
user = auth.sign_in_with_email_and_password('yigitcolakohlu@gmail.com', 'Ygtclksbl1')
user = auth.sign_in_with_email_and_password('yigitcolakohlu@gmail.com', 'FoodWro2018')
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_2_prod = {'Prod_Name':"Chocolate", 'BBD':"28.01.2019",'Nutrients':['Lactose','Glucose','Cocoa'],'Calories':180,'Cooked':False,'Allergens':[""],'Problematic':False,'Process':''}
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_proc = {'Harvested':{'Date':'24.04.2018','Location':'','Product':''},'Transport1':{'Duration':0,'Moved to,from':'-','Condition':0,'Stopped':False},'Process':{'Location':'','Processes':''},'Transport1':{'Duration':0,'Moved to,from':'-','Condition':0,'Stopped':False},'Packaging':{'Location':'','Material':'','Cancerogen':''}}
database_content = db.child("Products").get().val()
def getDate(product):


+ 58
- 0
Barcode_Reader_Python/database_append.py View File

@ -0,0 +1,58 @@
import pyrebase
config = {
"apiKey": "AIzaSyD3bXRjLxEAVOKtj8hpjO4iI3Nn32F7agU",
"authDomain": "foodcloud-f6eb1.firebaseapp.com",
"databaseURL": "https://foodcloud-f6eb1.firebaseio.com/",
"storageBucket": "foodcloud-f6eb1.appspot.com"
}
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
user = auth.sign_in_with_email_and_password('yigitcolakohlu@gmail.com', 'FoodWro2018')
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}}
Products = [data_1_prod, data_2_prod]
Processes = [data_1_proc, data_2_proc]
for i in range(len(Products)):
db.child("Products").child(str(i + 1)).set(Products[i])
for i in range(len(Processes)):
db.child("Processes").child(str(i + 1)).set(Processes[i])

+ 2
- 3
Barcode_Reader_Python/main.py View File

@ -85,8 +85,7 @@ while reps<1:
break
print("[INFO] cleaning up...")
print dates
print generate_moves.generate(dates,current_date)
moves = generate_moves.generate(dates,current_date)
#move(moves)
cv2.destroyAllWindows()
vs.stop()

+ 0
- 1
Barcode_Reader_Python/move.py View File

@ -1 +0,0 @@

Loading…
Cancel
Save