26
Sep

Default argument values for functions are a nice shortcut in python. They save you from writing many wrapper functions and make the code more readable and also easier to use. They can be used wrong though:

>>> def foo(a=[]):
...     a.append('bar')
...     return a
...
>>> foo()
['bar']
>>> foo()
['bar', 'bar']

Like described in idiomatic python, using a value which is a refenence (like a list, dict or instance) can lead to odd results. This is because the arguments are evaluated at compile time, not at runtime when the function is called! Instead of creating an empty list as one (inexperienced) would suspect, the default value becomes a reference to a list.

This can be nasty when it is used like this:

>>> def bar(time=datetime.now()):
...     print time
...
>>> bar()
2008-09-26 12:32:23.598052
>>> bar()
2008-09-26 12:32:23.598052

Just like in idiomatic Python, this is a good fix:

>>> def bar(time=None):
...     if time == None:
...             time = datetime.now()
...     print time
...
>>> bar()
2008-09-26 12:35:02.258992
>>> bar()
2008-09-26 12:35:03.059305

Instead of the default argument datetime.now(), using None, and later setting the current time instead of None works fine!

15
Sep

Today we did our first successful test, the terminal was interacting with MyPL properly, movements were retrieved and were signed off successfully.
The error reporting also worked, it sends an email and it should move on to the next movement. This could not be tested because there were no other movements available at the moment.

A big yaay!

Now;

  • Improve the menu structure on the terminal, to make it show it is doing something.
  • Still some problems with wireless access points.
  • Think up some usefull errors names.
  • Fix held key/press key twice problem.
11
Sep

Write doctests. Always write unittests. Aim for a test coverage of at least 80%. The higher the better.

Name                                                                                                   Stmts   Exec  Cover   Missing
--------------------------------------------------------------- --------------------------------------------------------------------
mypl/MockKerneladapter                                                                                    22     18    81%   41, 51, 57, 69
mypl/__init__                                                                                              0      0   100%
mypl/belege                                                                                              148     23    15%   22-26, 30-66, 71-73, 79-80, 87-91, 96-119, 124-128, 132-177, 181-182, 189-193, 198-233
mypl/models                                                                                              596    238    39%   69-72, 160, 165-172, 178, 183-186, 192-197, 203-208, 212-243, 251-311, 316-320, 326-340, 344-353, 358-363, 368-373, 377-398, 402-408, 412-423, 429-430, 434, 498-511, 515, 552, 558-562, 568-575, 580-618, 623-634, 638-641, 653-678, 684-690, 695-697, 702-705, 713-714, 734, 756, 781-783, 790, 795-797, 801-815, 822-823, 834-846, 851-855, 860-864, 870-889, 895-902, 908, 914-922, 929-938, 945-963, 973-985, 990-991, 995
mypl/tests                                                                                               132     99    75%   49-51, 56-59, 65-68, 74-77, 83-100, 148, 269
mypl/tools                                                                                                69      8    11%   16-39, 46-56, 62-71, 78-84, 91-98, 103-110
mypl/urls                                                                                                  6      6   100%
mypl/utils                                                                                                72      9    12%   31-39, 45-57, 65-73, 95-123, 139-148, 161-163, 167-168
mypl/views                                                                                               243     84    34%   34-77, 99-129, 141-158, 170-192, 204-259, 265-289, 295-317, 322-359, 410-411, 420-425, 436, 491

hmmm….

14
Aug

Today Tobias and me tested some options for determining the height of the fork on the forklifts using RFID. These options are very similar to the barcode option. After the first test we noticed when the tag was on a metallic surface the range decreased severely from 7cm to 3cm (estimated).

A quick google search found some interesting papers/advertisements confirming this. Nicely enough these result also gave some basic (and very obvious of course) tips on how to avoid and work the diminished range.

One of the tips was to get some distance between the metal and the tag. We tried it, and it worked better, but mainly because it was closer to the reader now.

07
Aug

Working with untested code written by someone else is not a good idea. So many strange assumptions can creep in…

Like assuming the writer of he code assumed that the serialize('json', attributes) accepted any kind of value. This is not true, it only accepts object fields.

But it gets and processes a movement order now!

31
Jul

I am working with code made by Chris (I think) which i pretty tightly coupled, or at least the function should be separated into several smaller functions with a clear purpose. code

from:
def stapler_holen(... 48 lines

to:
def stapler_holen(request, stapler_id): 9 lines
def _get_existing_job(stapler_id): 24 lines
def _create_stapler_job(stapler_id): 25 lines

stapler_holen is just a controller now, while the other 2 functions are more like library functions.

This is more lines of code, but the functions are somewhat better documented. The functions have a clear purpose now, with proper in function error handling. The functions also try not to do do other stuff.

28
Jul

In stead of a barode scanner, we can also use a RFID reader that operates on a different frequency, then the other (long range) reader to avoid collisions.

28
Jul

The dutch have an expression: “Door de bomen het bos niet meer zien” whih rougly translates to “because of the trees i am unable to see the forrest”. There are too many RFID readers out there, and stuff like these two make it even more confusing pmgp25a pmgp25

These are the same readers (as far as i can tell) only the description of the casing is different. Also this thing is not described very well, what are the connections actually on there? is it serial RS-232 with ASCII? is it TTL?

When its TTL, I don’t want it, it requires me to interface it to RS-232. I’d rather buy an off the shelve product that can easily be ordered later on instead of something that requires soldering.

The description sucks, its written for managers, and i do not know which tags it can actually read, “easily intergratable”, this sounds like a trap, yet it is the only “long range” reader i have found. it is also the only cheap one.

[Edit:] ofcourse.. a few minutes later after ranting… i find this

25
Jul

Got an answer from the guys where I ordered the RFID kit. No anti collision, maybe it will be in the new version they’re working on currently.

I looked at many RFID readers today, only the big and expensive do anti collision. Big doesn’t go well on a forklift.

On with solutions for this,
RFID still being used for the positioning and a barcode scanner for determining the height. This way we can use a normal (longer range) RFID scanner.

These are some longer range Readers. (even cheaper then the one from the kit)
In dutch/english ;)
promag_promag_rfid_lezer
promag_promag_rfid_lezer
promag_promag_gp30_mid
promag_promag_rfid_lezer

check which tags to use and which range is needed is the next step.

[edit:] they do not deliver outside of the netherlands… hmm…
mercateo has the product too.

24
Jul

Today the RFID development kit arrived even though it is more a trail kit. It contains a reader, power supply + rs232cable and 4 different RFID tags.

This reader is one big fail for our forklift purpose though, the range is severely limited (5 cm) and the reader does not do anti collision.

The power supply also needs a bit of work, but that will be manageable (does not have a nice power plug like the hand scanner does).

it’s not all bad. A big plus is the documentation that is delivered with the kit. short and containing enough information about the readers to get something useful out of it.

The scanner does work, works fast and seemingly accurate. It comes in a nice casing (which is way bigger then the electronics in it)

Waiting for a reply now and playing around with the readers and tags a bit more. but with the current distance its not promising.