I want to visualize where and how many people are in the factory

Introduction

Apparently, when working in a factory, it may be difficult to know where and how many people are. In that case, even if the machine stops, it seems that it will not be known whether it stopped due to lack of personnel or whether the machine detected an abnormality and stopped. So, let's easily visualize where and how many people are in the factory.

Make a factory layout

Let's express the initial layout of the factory in a two-dimensional layout. It also writes it to a csv file (data.csv) so that you can edit it later.

init_map.py


import csv
landmap = [[0 for i in range(21)] for j in range(5)]
for i,line in enumerate(landmap):
    print(str(i) + ":", end="")
    for area in line:
        print(area, end="")
    print()
with open('data.csv', 'w') as f:
    writer = csv.writer(f)
    writer.writerows(landmap)
#Execution result
0:000000000000000000000
1:000000000000000000000
2:000000000000000000000
3:000000000000000000000
4:000000000000000000000

Initial placement

The image is that the workers will do this on their smartphones when they arrive at the place before starting work at the factory. First, read data.csv as a numerical value. Ask the workers to use standard input to enter where they will start working (such as Aiue with this code). Create a function that increments the number of people in the place you entered. Use a function to perform the process. Finally, write this processed content to data.csv and update data.csv.

start_arran.py


landmap=[list(map(int,line.rstrip().split(","))) for line in open('data.csv').readlines()]
import csv
a = input('Where are you')
def start_where(s):
    if 'A' in s:
        landmap[0][0] +=1
    elif 'I' in s:
        landmap[0][5] +=1
    elif 'C' in s:
        landmap[0][10] +=1
    elif 'D' in s:
        landmap[0][15] +=1
    elif 'Oh' in s:
        landmap[0][20] +=1
    elif 'Mosquito' in s:
        landmap[2][0] +=1
    elif 'Ki' in s:
        landmap[2][5] +=1
    elif 'Ku' in s:
        landmap[2][10] +=1
    elif 'Ke' in s:
        landmap[2][15] +=1
    elif 'Ko' in s:
        landmap[2][20] +=1
    elif 'Service' in s:
        landmap[4][0] +=1
    elif 'Shi' in s:
        landmap[4][5] +=1
    elif 'Su' in s:
        landmap[4][10] +=1
    elif 'Se' in s:
        landmap[4][15] +=1
    elif 'So' in s:
        landmap[4][20] +=1
    else:
      print('error')

start_where(a)
for i,line in enumerate(landmap):
    print(str(i) + ":", end="")
    for area in line:
        print(area, end="")
    print()
with open('data.csv', 'w') as f:
    writer = csv.writer(f)
    writer.writerows(landmap)
#Execution result
Where are you
0:000000000000000000000
1:000000000000000000000
2:000000000000000000000
3:000000000000000000000
4:000000000000000000001

Where are you
0:100000000000000000000
1:000000000000000000000
2:000000000000000000000
3:000000000000000000000
4:000000000000000000001

Where are you
0:100000000000000000000
1:000000000000000000000
2:000000000010000000000
3:000000000000000000000
4:000000000000000000001

Move placement

In factories, we sometimes move the placement, and because of that, we may not know where and how many people are placed, so we will consider what to do when we move the place. Decrease the number of people in the place you used to be by -1, and add +1 to the number of people in the newly moved place.

move.py


landmap=[list(map(int,line.rstrip().split(","))) for line in open('data.csv').readlines()]
import csv
a = input('Where are you?')
b = input('Where are you going')
def now_where(s):
    if 'A' in s:
        landmap[0][0] -=1
    elif 'I' in s:
        landmap[0][5] -=1
    elif 'C' in s:
        landmap[0][10] -=1
    elif 'D' in s:
        landmap[0][15] -=1
    elif 'Oh' in s:
        landmap[0][20] -=1
    elif 'Mosquito' in s:
        landmap[2][0] -=1
    elif 'Ki' in s:
        landmap[2][5] -=1
    elif 'Ku' in s:
        landmap[2][10] -=1
    elif 'Ke' in s:
        landmap[2][15] -=1
    elif 'Ko' in s:
        landmap[2][20] -=1
    elif 'Service' in s:
        landmap[4][0] -=1
    elif 'Shi' in s:
        landmap[4][5] -=1
    elif 'Su' in s:
        landmap[4][10] -=1
    elif 'Se' in s:
        landmap[4][15] -=1
    elif 'So' in s:
        landmap[4][20] -=1
    else:
      print('error')

def move(s):
    if 'A' in s:
        landmap[0][0] +=1
    elif 'I' in s:
        landmap[0][5] +=1
    elif 'C' in s:
        landmap[0][10] +=1
    elif 'D' in s:
        landmap[0][15] +=1
    elif 'Oh' in s:
        landmap[0][20] +=1
    elif 'Mosquito' in s:
        landmap[2][0] +=1
    elif 'Ki' in s:
        landmap[2][5] +=1
    elif 'Ku' in s:
        landmap[2][10] +=1
    elif 'Ke' in s:
        landmap[2][15] +=1
    elif 'Ko' in s:
        landmap[2][20] +=1
    elif 'Service' in s:
        landmap[4][0] +=1
    elif 'Shi' in s:
        landmap[4][5] +=1
    elif 'Su' in s:
        landmap[4][10] +=1
    elif 'Se' in s:
        landmap[4][15] +=1
    elif 'So' in s:
        landmap[4][20] +=1
    else:
      print('error')


now_where(a)
move(b)
for i,line in enumerate(landmap):
    print(str(i) + ":", end="")
    for area in line:
        print(area, end="")
    print()
with open('data.csv', 'w') as f:
    writer = csv.writer(f)
    writer.writerows(landmap)
#Execution result
Where are you? A
Where are you going Ko
0:000000000000000000000
1:000000000000000000000
2:000000000010000000001
3:000000000000000000000
4:000000000000000000001

Summary

It's very simple and dirty code, but I've drawn programming that lets you know where and how many people are in the factory.

What you want to be a plus

Each ability of the worker is summarized in Excel etc. in 5 stages in advance, and since the position of A requires a total of N abilities of hoge, Mr. A and Mr. B are automatically assigned. As a result, if the number of people is insufficient and an alert appears, it would be interesting to create an algorithm that automatically changes the staffing by adding + N to the required capacity of the place.

Recommended Posts

I want to visualize where and how many people are in the factory
I want to analyze the emotions of people who want to meet and tremble
I want to display the progress in Python!
I want to get the file name, line number, and function name in Python 3.4
I want to write in Python! (3) Utilize the mock
I want to use the R dataset in python
I want to replace the variables in the python template file and mass-produce it in another file.
[Memorandum] ① Get and save tweets ~ I want to identify the news tweets that are spread ~
I tried to illustrate the time and time in C language
How to get all the keys and values in the dictionary
I want to know the features of Python and pip
I want to make the Dictionary type in the List unique
I want to count unique values in arrays and tuples
I want to map the EDINET code and securities number
I want to align the significant figures in the Numpy array
I didn't want to write the AWS key in the program
I tried to summarize what python strong people are doing in the competition professional neighborhood
I want to record the execution time and keep a log.
[Linux] I want to know the date when the user logged in
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
How to give and what the constraints option in scipy.optimize.minimize is
LINEbot development, I want to check the operation in the local environment
I want to create a pipfile and reflect it in docker
I summarized how to change the boot parameters of GRUB and GRUB2
I want to make the second line the column name in pandas
I want to connect remotely to another computer, and the nautilus command
I want to pass the G test in one month Day 1
How to visualize where misclassification is occurring in data analysis classification
I want to know the population of each country in the world.
People memorize learned knowledge in the brain, how to memorize learned knowledge in machine learning
How to display bytes in the same way in Java and Python
I want to pin Spyder to the taskbar
I want to change the color by clicking the scatter point in matplotlib
I want to output to the console coolly
I want to print in a comprehension
I tried to visualize the age group and rate distribution of Atcoder
I want to separate the processing between test time and production environment
I tried to summarize the methods that are often used when implementing basic algo in Quantx Factory
How to write the correct shebang in Perl, Python and Ruby scripts
I want to handle the rhyme part1
I want to know how LINUX works!
[C language] I want to generate random numbers in the specified range
I want to handle the rhyme part3
How to get the date and time difference in seconds with python
How to compare if the contents of the objects in scipy.sparse.csr_matrix are the same
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I want to sort a list in the order of other lists
I want to use the Django Debug Toolbar in my Ajax application
The file name was bad in Python and I was addicted to import
I want to display the progress bar
I want to leave an arbitrary command in the command history of Shell
I want to embed Matplotlib in PySimpleGUI
How to use is and == in Python
I implemented the VGG16 model in Keras and tried to identify CIFAR10
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I want to get the path of the directory where the running file is stored.
I want to visualize the transfer status of the 2020 J League, what should I do?
How to pass the path to the library built with pyenv and virtualenv in PyCharm