Design and PrototypicalImplementation of Digitalized Cow
Paddock Journal
Simon BachmannZurich, Switzerland
Student ID: 14-709-893
Supervisor: Thomas Bocek, Markus HurschlerDate of Submission: July 15, 2017
University of ZurichDepartment of Informatics (IFI)Binzmühlestrasse 14, CH-8050 Zürich, Switzerland ifi
SO
FT
WA
RE
PR
OJE
CT
–C
omm
unic
atio
nS
yste
ms
Gro
up,P
rof.
Dr.
Bur
khar
dS
tille
r
Software ProjectCommunication Systems Group (CSG)Department of Informatics (IFI)University of ZurichBinzmühlestrasse 14, CH-8050 Zürich, SwitzerlandURL: http://www.csg.uzh.ch/
Abstract
Research showed that the Swiss agriculture sector shows many possibilities to improveproductivity with modern IT-systems. This Software Project focuses on the design andthe implementation of a digitized cow paddock journal where farmers can record the fieldlairage on their smartphone. The goal is to combine the existing IT-infrastructure with anewly designed RESTful API in the back end and an Android as well as an iOS applicationin the front end.
i
ii
German Summary
In der Schweiz konnen sich Bauern anhand von Direktzahlungen ein Grundeinkommensichern. Diese Zahlungen haben unter anderem die Absicht, besonders naturnahe, umwelt-und tierfreundliche Produktionsformen zu fordern. Ein Teil von diesem Programm ist dasAuslaufsjournal. In diesem Journal wird festgehalten, welche Tiere an welchen Tagen aufdie Weide gefuhrt worden sind. Dieses Journal wird von jedem Kanton als Downloadfur die Bauern zur Verfugung gestellt. Ein Beispiel vom Kanton Glarus ist in Figure1.1 gezeigt. Dieses Journal wird von den Bauern von Hand ausgefullt. Dabei ist zubeachten, dass jede Kuh in eine der neun Kuhkategorien eingeteilt werden muss. Diesesind in der Abbildung unterhalb der Tabelle zu sehen. Der Aufwand, um dieses Journalzu unterhalten, wachst mit der Grosse der Betriebes.
In diesem Software Projekt wird der Erstellungsprozess dieses Journals untersucht, einSystem konzipiert und implementiert, welches diesen Prozess erleichtern soll. Das Sys-tem ist mit der TVD verbunden. Aus der TVD konnen Details zu den einzelnen Tierenbezuglich Alter, Geschlecht und letztes Kalberungsdatum geladen werden und somit kon-nen die Tiere automatisch kategorisiert werden. Die Registrierung eines neuen Eintragesim digitalisierten Auslaufjournal kann mithilfe der Android- und iOS-Applikation gemachtwerden. Es ist moglich, eine Anfrage an das System zu machen, um den Status des Aus-laufjournals fur einen bestimmten Betrieb zuruck zu bekommen, ob die Anforderungeneingehalten wurden oder nicht. Dies ist wichtig, wenn ein Kontrolleur das Journal einesBauern uberprufen will.
iii
iv
Acknowledgments
I would like to express my sincere gratitude to my supervisor, Dr. Thomas Bocek forthe continuous support of my Software Project for his patience, motivation and profoundknowledge.
I would also like to thank Markus Hurschler for his supervision. He was always veryhelpful and provided many insightful inputs about the agricultural background to thisSoftware Project.
Besides my supervisors I would also like to thank Prof. Dr. Burkhard Stiller, the head ofthe Communication Systems Research Group, for giving me the opportunity to work onsuch an interesting topic.
v
vi
Contents
Abstract i
German Summary iii
Acknowledgments v
1 Introduction 1
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Description of Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Related Work 5
2.1 Regulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 TVD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 aPayment - Master Thesis by Moritz Schneider . . . . . . . . . . . . . . . 6
2.4 React-Native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4.1 The JavaScript Runtime Environment Architecture (Bridging) . . . 7
2.4.2 Single Rendering Entry Point . . . . . . . . . . . . . . . . . . . . . 8
3 Design and Implementation 11
3.1 Ethereum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Smartbow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 SOAP Interface to the TVD . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.4 JWT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
vii
viii CONTENTS
3.5 REST API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.6 Front End . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.6.1 Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.6.2 Dashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.6.3 Creating New Journal Entry . . . . . . . . . . . . . . . . . . . . . . 18
3.6.4 Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4 Evaluation 25
4.1 Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Usability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5 Summary and Conclusions 29
Bibliography 31
Abbreviations 33
Glossary 35
List of Figures 35
List of Tables 37
A Installation Guidelines 41
A.1 Front End - ReactNative Application . . . . . . . . . . . . . . . . . . . . . 41
A.1.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
A.1.2 Simulate for iOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
A.1.3 Simulate for Android . . . . . . . . . . . . . . . . . . . . . . . . . . 42
B Contents of the CD 43
Chapter 1
Introduction
1.1 Motivation
Swiss farmers maintain a cow paddock journal (”Auslaufjournal”) in order to receive sub-sidies from the government. Most farmers print out a copy of a cow paddock journaltemplate, which is provided by the canton, and report which cows have spent the dayoutside of the stable. An example of such a template for the months of January untilJune 2017 from the canton of Glarus is shown in Figure 1.1.
In order to receive subsidies from the government, an animal husbandry has to fulfillcertain criteria which are presented in Section 2.1.
This can become a real administrative effort for large farms with many animals. Anapplication that categorizes the cows automatically and that can be maintained from amobile phone can simplify the process.
The cow paddock journals are regularly checked by government. Inspectors are peoplethat are issued by the government and visit farms unannounced to review the cow pad-dock journals (among other journals for different subsidies). The time and effort that isneeded to check all the journals of an applicant for subsidies may take several hours. Anapplication that automatically checks if the farmer has fulfilled the requirements and letsthe inspector know about the result, could shorten the process of testing the cow paddockjournal. A prototype of a system that focusses on direct payments is designed as part ofa Master Thesis at the University of Zurich and described in more detail in Section 2.3.
The conception of a digitized cow paddock journal is that each cow is tracked by a loca-tion sensor and therefore, the records in the cow paddock journal can automatically begenerated depending on the cows location. The daily administrative effort for the farmercan be reduced and the challenging task of verifying the journal for the inspector can besimplified.
1
2 CHAPTER 1. INTRODUCTION
J
an
ua
r F
eb
rua
r M
ärz
A
pri
l M
ai
J
un
i
Tie
rkate
go
rien
Tie
rkate
go
rien
Tie
rkate
go
rien
Tie
rkate
go
rien
Tie
rkate
go
rien
Tie
rkate
go
rien
11
11
11
22
22
22
33
33
33
44
44
44
Pfi
ng
ste
n
55
55
55
Pfi
ng
stm
on
tag
66
66
66
77
77
77
88
88
88
99
99
99
10
10
10
10
10
10
11
11
11
11
11
11
12
12
12
12
12
12
13
13
13
13
13
13
14
14
14
14
Karf
reit
ag
14
14
15
15
15
15
15
15
16
16
16
16
Oste
rn1
61
6
17
17
17
17
Oste
rmo
nta
g1
71
7
18
18
18
18
18
18
19
19
19
19
19
19
20
20
20
20
20
20
21
21
21
21
21
21
22
22
22
22
22
22
23
23
23
23
23
23
24
24
24
24
24
24
25
25
25
25
25
Au
ffah
rt2
5
26
26
26
Be
gin
n S
om
me
rze
it2
62
62
6
27
27
27
27
27
27
28
28
28
28
28
28
29
29
29
29
29
30
30
30
30
30
31
31
31
Su
mm
e W
Su
mm
e L
Erl
äu
teru
ng
en
: W
= W
eid
e L
= L
au
fho
f S
= S
öm
me
run
gE
intr
äg
e s
pä
tes
ten
s n
ac
h 3
Ta
ge
nU
nte
rsch
rift
Be
wir
tsch
aft
er:
D
ies
es
Fo
rmu
lar
ist
wä
hre
nd
min
de
ste
ns
6 J
ah
ren
au
fzu
be
wa
hre
nU
nte
rsch
rift
Ko
ntr
olle
ur:
Tie
rka
teg
ori
en
:(A
ufz
äh
lun
g n
ich
t a
bsc
hlie
sse
nd
)A
1M
ilch
küh
eA
7m
än
nlic
he
Tie
re 3
65
bis
73
0 T
ag
eC
1Z
ieg
en
üb
er
1 J
ah
r a
ltE
5R
em
on
ten
bis
1/2
jäh
rig
u. M
ast
sch
we
ine
A2
an
de
re K
üh
eA
8m
än
nlic
he
Tie
re 1
60
bis
36
5 T
ag
eD
1S
cha
fe >
1 J
ah
r u
nd
We
idlä
mm
er
G1
Zu
chth
en
ne
n u
nd
Zu
chth
äh
ne
(B
rute
ierp
rod
ukt
ion
)A
3R
ind
er
we
ibl.
> 3
65
Tg
. b
is z
ur
Ab
kalb
A9
mä
nn
lich
e T
iere
bis
16
0 T
ag
eE
1Z
uch
teb
er
üb
er
ha
lbjä
hri
gG
2L
eg
eh
en
ne
nA
4R
ind
er
we
ibl.
16
0 b
is 3
65
Ta
ge
B1
we
ibl.
un
d k
ast
r. P
ferd
e >
30
Mte
. a
lt E
2n
ich
t sä
ug
en
de
Zu
chts
au
en
üb
er
ha
lbjä
hri
gG
3
Jun
gh
en
ne
n, Ju
ng
hä
hn
e u
nd
Kü
cke
nA
5R
ind
er
we
ibl.
bis
16
0 T
ag
eB
2H
en
gst
e >
30
Mte
. a
ltE
3sä
ug
en
de
Zu
chts
au
en
G4
Ma
stp
ou
lets
A6
mä
nn
lich
e T
iere
üb
er
73
0 T
ag
eB
3P
ferd
e b
is 3
0 M
te. a
lt E
4
ab
ge
setz
te F
erk
el
G5
Tru
ten
S
on
nta
ge
Vors
chrif
ten
für R
indv
ieh:
RAU
S-B
etrie
be →
Vom
1. M
ai b
is z
um 3
1. O
ktob
er 2
6 x
pro
Mon
at W
eide
gang
, in
der ü
brig
en Z
eit 1
3 x
pro
Mon
at A
usla
uf in
s Fr
eie
Aus
lauf
jour
nal f
ür d
as J
ahr 2
017
Bew
irtsc
hafte
r: …
……
……
……
……
……
……
..
Alle
übr
igen
Bet
riebe
→ (G
rund
lage
Tie
rsch
utzg
eset
z): R
egel
mäs
sig
wäh
rend
min
d. 9
0 Ta
gen
Aus
lauf
pro
Jah
r, da
von
30 T
age
wäh
rend
der
Win
terf
ütte
rung
Figure 1.1: Cow Paddock Journal [4]
1.2. DESCRIPTION OF WORK 3
1.2 Description of Work
The goal of this Software Project is the design and implementation of a digitized cowpaddock journal. The application will provide a mobile interface for farmers for registeringthe days that a cow has spent outside of the stable. The farmer needs to be able to storethe amount of days for each individual cow every day. This is important since the datafor the cow paddock journal might be coupled with sensors in a later project. Therefore,every cow needs to be registered separately, which differentiates from today’s registrationstandard where only the amount of animals in each category is stored. Each cow isidentified by the earmark provided by Identitas AG. A user friendly interface shouldmake the registration for the cow paddock journal as similar to the today’s registration aspossible. The main target platform of the application is Android.
The back end of the system consists of a RESTful API that is also connected to TVD inorder to retrieve more information about each individual cow. With the information ofthe TVD a cow can automatically be categorized which is important when creating thecow paddock journal. At the moment it is not clear if a single sign-on with the login tothe TVD is possible or not. If single sign-on is not possible, an authentication solutionwith access tokens should be implemented.
Furthermore, an inspector is person that is commissioned by the government to check ifthe journal of a specific farm is maintained correctly. Therefore, the system should allowan inspector to gain access to the digitized cow paddock journal of the farm that needs tobe validated.
1.3 Thesis Outline
Chapter 1 is about the regulations and general process of maintaining the cow paddockjournal and show the motivation for a new digitized system. Also the project scope andgoals are defined. Chapter 2 contains detailed information about the regulations of thecow paddock journal as well as the TVD and the Master Thesis of Moritz Schneiderand about how the architecture of React-Native works. Chapter 3 also includes all theinformation about the design and implementation details of the RESTful API as well asthe mobile application. In Chapter 4, the system is evaluated by revising the initially setaims. At last, Chapter 5 concludes the Software Project.
4 CHAPTER 1. INTRODUCTION
Chapter 2
Related Work
2.1 Regulations
According to the Verordnung uber die Direktzahlungen an die Landwirtschaft (Regulationon direct payments to agriculture) an animal husbandry who participates in the subsidiesprogram has to follow the subsequent guidlines:
• The farmer has to make sure that the cows spend at least 26 days outside duringthe summer months (May – October) and at least 13 days during the winter months(November – April). Farms that have not subscribed to the subsidies program mustprove that the animals spend at least 90 days outside during the year where 30 dayshave to be during the winter months. This is due to the Protection of Animal Act[2].
• Every field lairage is distinguished by one of three different types of field lairage –pasture (”Weide”), farmyard (”Laufhof”) or mountain grazing (”Sommerung”).
• Every entry in the cow paddock journal has to be reported within three days [3].
• Each record has to be stored at least for six years [5].
• Furthermore, every cow has to be categorized in one of the nine categories dependingon its sex, age last calving date [6]. These categories are listed in Figure 1.1 belowthe table and a more detailed description is shown in Table 3.9. For this projectonly the cow categories are relevant (A1–A9).
If an inspector can prove that a farmer has violated any of these rules, the farmer is fined.In severe disobedient the farmer may be banned entirely from the subsidies program [15].
5
6 CHAPTER 2. RELATED WORK
2.2 TVD
Identitas AG is a company that focuses on the registration and traceability of Swiss farmanimals. The company uses one large database called TVD to store this information.On behalf of the Federal Office for Agriculture, the TVD assigns identities in the formof unambiguously labeled ear tags to all clawed animals kept in Switzerland (cattle, pigs,sheep, goats and wild game). Since the year 2000 the TVD records all births, relocationand slaughter of cattle. In 2011 the registration requirement was extended to equids(horses, donkeys and mules). Since the same date, the TVD also records the accessionsof pigs and their slaughtering [7].
2.3 aPayment - Master Thesis by Moritz Schneider
Moritz Schneider concurrently works on a Master Thesis where direct payments are furtherinvestigated. The goal of this Master Thesis is to design and prototype a system basedon blockchain technology that increases the transparency and automates interactions inthe agriculture sector.
The system enables farmers to request direct payments. On the other side, the governmentrecruits people that inspect farms which applied to the subsidies program. In order toreceive money from the government, farmers need to fulfill certain criteria. The process ofchecking these journals is time-consuming and expensive. Therefore, the system providesa request-specific checklist to the inspector in order to validate the application of thedeclared farm, which simplifies the process of testing the subsidies journals.
The automated payment process through the Ethereum blockchain is another feature ofthe system. Due to the high volatility, the system does not payout the direct paymentswith Ethers. Instead, a new stable cryptocurrency which is bound to the Swiss franc –the aPayment Token – is implemented.
During the process of inspecting the subsidies journals, the aPayment system requests thevalidity of the cow paddock journal from the system that is created within this SoftwareProject (RAUS API) as shown in Figure 2.1. By submitting an array of ear tag numbers ofcows, the RAUS API system checks if these cows meet the requirements of the governmentfor receiving the subsidies.
2.4. REACT-NATIVE 7
Figure 2.1: Relation between the aPayment system and the RAUS API
2.4 React-Native
React-Native is a JavaScript framework for developing cross-platform mobile applicationthat is created by Facebook and officially made available in March 2015.
Other JavaScript framework such as Cordova embed HTML5 code inside WebView whichessentially is a web browser that can make use of the native APIs. A big downside ofthese hybrid applications are the performance difference compared to a native application,especially for graphical-intense applications. The mobile operating system also does notprovide all its features to a WebView. The user experience on a hybrid application can alsodiffer from native applications, this may happen due to the application or the platformitself. This problem may range from scroll bars feeling differently to noticeable delay whenpressing on UI components. React-Native tries to overcome these problems by introducingnew concepts, which are discussed in the following sections.
2.4.1 The JavaScript Runtime Environment Architecture (Bridg-ing)
Since JavaScript is not the programming language that nativly runs on any mobile phone,a technique called bridging has to be introduced first. Bridging enables the communicationbetween the JavaScript program and the processor of the phone. Therefore, the phoneruns a process that is called the JavaScript Runtime Environment in order to enable theexecution of JavaScript code.
JavaScript must use the underlying native code to operate a native application. Thereare multiple instances of native code that each application needs to use such as navigation
8 CHAPTER 2. RELATED WORK
or button control. And it does this by setting up each control in the JavaScript runtimeenvironment and then communicating across the bridge as shown in Figure 2.2.
Figure 2.2: Bridge between the Native Code and the JavaScript Runtime Environment
The JavaScript Runtime Environment is operation as an independent thread. Therefore,if the JavaScript code does a computationally intensive work or waits for a response, thenative UI components do not slow down. It simply calls back across the bridge usingevents [14].
React-Native solves with this architecture the biggest problem of hybrid applications –the performance. Although, an application that crosses the bridge too frequently can alsonoticeably slow down the application.
2.4.2 Single Rendering Entry Point
UI elements in React-Native are constructed by components. Every component can beconstructed from other components and has its own render method. This render methodalways returns XML-based construct which is the representation of the UI structure andconsists of React components. This results in a tree-like structure – similar to the DOMin web technology. Components cannot be rendered anywhere else than inside the renderfunction.
Re-render on Changes
React-Native uses an algorithm called Diff Algorithm [12] just like ReactJS in order togenerate a virtual DOM which detects changes in any of the components between the
2.4. REACT-NATIVE 9
prior (virtual) state and the current (virtual) state. Only the affected components arere-rendered [11]. This mechanism makes it possible to minimize the amount of datathat is sent over the bridge and therefore enables the good performance of React-Nativeapplications [13].
10 CHAPTER 2. RELATED WORK
Chapter 3
Design and Implementation
3.1 Ethereum
As stated in the Verordnung uber die Direktzahlungen an die Landwirtschaft (Regulationon direct payments to agriculture) [3] every entry in the cow paddock journal has tobe reported within three days. Initially a decentralized system design on the Ethereumblockchain was intended. Although, updating the journal for each cow every three daysresults in too many blockchain transactions. Therefore, a decentralized approach is infea-sible.
3.2 Smartbow
Smartbow [1] is an Austrian company that manufactures electronic ear tag numbers forfarm animals that allow real time localization. A fully automated system with Smartbowsensors was not possible during this project - due to the readiness of the sensors. For thisreason the registration process of the cow paddock journal should be made possible witha mobile application.
3.3 SOAP Interface to the TVD
The TVD uses the Simple Object Access Protocol (SOAP) for exchanging data. Withaccess to the TVD, the system can request detailed information about Swiss farm animals.Identitas AG provides a manufacturer key and a farmer login to the test network. Withthis information the system can request detailed information such as the gender, birthdate and latest calving date of live stock of an animal husbandry. Therefore, the systemcan categorize cows into one of the nine default categories (described in more detail inTable 3.1).
11
12 CHAPTER 3. DESIGN AND IMPLEMENTATION
Identitas AG cannot provide an admin login which can load information about any animalhusbandry. Therefore, every farmer has to provide a TVD number, Agate number andAgate password when signing up. These credentials are then used for accessing the TVD.
The TVD does not support single sign-on. Therefore, the system needs its own authenti-cation system which is described in more detail in Section 3.4.
3.4 JWT
Due to the fact that the TVD does not support a single sign-on, the system needs adifferent approach to deal with authentication. Therefore, the system uses the JSONWeb Token (JWT) standard which is compact and self-contained. It is compact since thestring length of the token is small enough to be sent inside the HTTP header and self-contained since it contains all the required information about the user, which eliminatesthe need to query the database more than once [8].
When a user successfully logs in to the system, a token is generated and sent back to theuser, which then can be used for further requests in order to authenticate himself andaccess protected endpoints.
3.5 REST API
The RESTful API consists of public and protected endpoints. The protected endpointsrequest a valid access token and provide information about the user itself, the farmer’sown cows, custom and automatically generated categories, details about the cow paddockjournal and monthly statistics of the default categories. More details about the endpointsare listed in Table 3.2.
A farmer can create his own groups of cows which makes the process of maintaining thecow paddock journal simpler. For example a farmer could store all the cows that are outon the field during the week in group and the ones that are outside on the weekend indifferent category.
There is one more endpoint for the requests done by inspectors. By providing a list of eartag numbers of cows one can request the validity of cow paddock journal for these cows.How the authentication is handled on this endpoint still needs to be discussed.
The system connects to a PostgreSQL database to store and manage the informationabout users, cow paddock journals and custom and default categories.
3.5. REST API 13
Description Sex Age in DaysDays since
Last Calving DateA1 Milk Cows f - <300A2 Other Cows - - -
A3Female Cows,
Older than 365 Days,until First Calving
f >= 365 No Calving Yet
A4Female Cows,
between 160 and365 Days Old
f >= 160 AND <365 -
A5Female Cows,
Younger than 160 Daysf <160 -
A6Male Cows,
Older than 730 Daysm >= 730 -
A7Male Cows,
Between 365 and730 Days Old
m >= 365 AND <730 -
A8Male Cows,Between 160
and 365 Days Oldm >= 160 AND <365 -
A9Male Cows,
less than 160 Days Oldm <160 -
Table 3.1: Categories
14 CHAPTER 3. DESIGN AND IMPLEMENTATION
Endpoint Method Protected Description/ GET No Returns the current status of API.
/get-token POST NoReturns a new JWT token which isneeded for all protected endpoints.
/sing-up POST NoA new user can be created with this
endpoint.
/me GET YesInformation about the logged in
user is returned.
/tester POSTNo
(not yet)
Check if the RAUS requirementsare satisfied for a given array of
ear tag numbers.
/cows GET Yes
Returns a list of cows that belongto the farmer that is requesting.Also returns detailed informationabout these cows such as name,gender, cow paddock journal.
POST YesLets a farmer create a new custom
category.
UPDATE YesLets a farmer update a custom
category./categories
DELETE YesLets a farmer delete a custom
category.
/cows-by-category GET YesReturns a list of custom as wellas default categories and all its
assigned cows.
/journal POST YesCreates a new journal entry fora given date and list of ear tag
numbers.
/stats GET YesReturns statistics about all thedefault categories for a given
month and year.
Table 3.2: Endpoints of the REST API
3.6. FRONT END 15
3.6 Front End
The mobile application was implemented with the JavaScript framework React-Native. Anadvantage of React-Native is that it runs JavaScript code and communicates with nativeUI components for the respective OS, Android or iOS - whereas other cross-platformframeworks like Cordova, Ionic run JavaScript powered apps in a web views. With React-Native one can build a native mobile application that is indistinguishable from an appbuilt using Swift or Java.
The graphical user interface is supposed to be as similar as possible to the known processof registering the cow paddock journal. In the next subsections it is explained how theapplication works and what the thought are behind the chosen design.
3.6.1 Navigation
When the application is opened up and the session token is still valid the dashboard isshown which is explained in more detail in Section 3.6.2. If the token is no longer validthe user is prompted with the login screen.
From the dashboard one can create a new cow paddock journal entry by pressing on theicon in the upper right corner. This process is shown in Section 3.6.3. By clicking onthe icon in the top left corner on the dashboard one opens the menu drawer for furthernavigation as shown in Figure 3.2. From here one can navigate to an overview of allcustom categories as well as the default categories which is discussed in Section 3.6.4.Within the categories menu, one can create a new category or edit existing categories.From the menu drawer one can also change the language of the application and can logout,which effectively deletes the session token and prompts the login screen.
3.6.2 Dashboard
The dashboard is used to illustrate the progress of the cow paddock journal for eachcategory for every month. These categories are automatically generated by the system asexplained in Section 3.3. There is horizontal scroll below navigation header which allowsto see the journal history of the past months. Only the overview of default categories areshown since only these categories are relevant for the subsidies. The progress bar for eachcategory indicates the lowest amount of days in dark green and highest amount of days ina brighter green for the selected month. Therefore, one can directly see what categorieshave already fulfilled the necessary amount of days outside.
One can get detailed information about a specific category by clicking on a category asshown in Figure 3.1b. On this screen the farmer can see which cows have spent how manydays outside.
Throughout the application the cow’s name is displayed if the owner has registered thecow’s name in the TVD. If no name is provided the cows ear tag is shown.
16 CHAPTER 3. DESIGN AND IMPLEMENTATION
(a) Overview (b) Detailed Category View
Figure 3.1: Dashboard
3.6. FRONT END 17
Figure 3.2: Menu Drawer for Navigation
18 CHAPTER 3. DESIGN AND IMPLEMENTATION
3.6.3 Creating New Journal Entry
By clicking the icon in the top right corner on the dashboard a new entry in the cowpaddock journal can be created. Firstly, the date for when the journal entry should becreated has to be set as shown in Figure 3.3. By default it is set to today’s date. Thedate can be changed in the tab bar below the header to yesterday’s date or a custom datein the past.
Figure 3.3: Date Selection
When the date picker is opened on an Android (Figure 3.4a) phone it looks different thanon an iOS device (Figure 3.4b). This is one of the big advantages of React Native and alsoapplies to many other design elements throughout the entire application such as colors,fonts, button styles, etc.
In the next step, the type of field lairage has to be chosen. There are the options ofpasture (”Weide”), farmyard (”Laufhof”) and mountain grazing (”Sommerung”). The tabbar below the header allows toggling between these three options as shown in Figure 3.5.
Lastly, one selects the cows that should receive an entry in the cow paddock journal. Belowthe header there is the summary of the date and the type of field lairage one selected inthe previous two steps and how many cows are selected from the section below. One can
3.6. FRONT END 19
(a) Android (b) iOS
Figure 3.4: Date Selection on different OS
easily select all the cows from a particular category by enabling the switch button (seeFigure 3.6a) or select each individual cow within the detailed category view (see Figure3.6b).
20 CHAPTER 3. DESIGN AND IMPLEMENTATION
Figure 3.5: Type of Field Lairage Selection
3.6. FRONT END 21
(a) Categories Overview (b) Detailed Category View
Figure 3.6: Cow Selection
22 CHAPTER 3. DESIGN AND IMPLEMENTATION
3.6.4 Categories
As already mentioned one can create his own groups of cows. By clicking on the icon inthe top left corner on the dashboard the menu drawer opens. From here one can navigateto an overview of all custom categories as well as the default categories (Figure 3.7). Moreinformation about the default categories are described in Table 3.1. Default categoriesand automatically generated categories are differentiated, since the default categoriescannot be changed. When selecting a category a detailed view of the selected category isprompted.
If the category is a custom category one can add and delete cows for this category (Figure3.8). By clicking the plus icon in the upper right corner within the categories overviewscreen a new category can be created as shown in Figure 3.10.
Figure 3.7: Custom and Automati-cally Generated Categories Overview
Figure 3.8: Custom Categories CanBe Edited
Figure 3.9: Categories
3.6. FRONT END 23
Figure 3.10: Category Creation
24 CHAPTER 3. DESIGN AND IMPLEMENTATION
Chapter 4
Evaluation
This chapter evaluates the RAUS API and compares its functionality and usability to theinitially set goals.
4.1 Functionality
The goal of designing and implementing a digitized cow paddock journal is achieved. Ananimal husbandry can create journal entries in the system by submitting a date, type offield lairage and a list of cows. The entries in the cow paddock journal are no longer basedon the category name (A1–A9) but instead based on the unique ear tag number of eachcow separately. The dashboard indicates the progress for each of the subsidies relevantcategories for the current month. A detailed schedule of each animal category can bedisplayed too.
Retrieving further details to individual animals from the TVD is possible. Therefore,each cow does not have to be registered individually. Instead, details about every cow isdirectly loaded from the TVD. Cows are automatically categorized into one of the ninedefault categories that are relevant for the subsidies.
The feature of creating custom categories is part of the system requirements. This featureis successfully implemented. Custom groups of cows can be created and updated whichsimplifies the process of registering the cow paddock journal.
An endpoint has been created in order to request the validity of the digitized cow paddockjournal for subsidies inspectors. The system checks if a given array of ear tag numbersfulfills the requirements for receiving subsidies. This endpoint is also part of the systemrequirements since this endpoint is integrated in a Master Thesis of the University whichis described in Section 2.3.
Identitas AG cannot provide a login that allows to load data about any user or animal inthe system. Therefore, the system uses the TVD login of each individual user that theuser has to provide when singing up, for making requests to the TVD. The consequenceof this inconvenience is that the user login to the TVD for every user has to be stored.
25
26 CHAPTER 4. EVALUATION
4.2 Usability
The graphical user interface is simple and similar to what farmers are used to. The targetplatform is supposed to be Android. Due to React Native it works on iOS too. Operatingsystem dependent UI components such as the date picker are implemented which flattenspeople’s the learning curve that are used to a specific operating system.
Since most request to the back end of the system trigger a further request to the TVDthe loading time is extended, which effective slows down the application. Postman is anAPI testing tool that allows to write tests for every endpoint [9]. Response time testwith 100 iterations showed that the loading time for the sign-in endpoint that does nottrigger a subsequent request to the TVD responds in 96% of the cases within 100ms withan average time of 27ms. A database similar complex endpoint but with a subsequentrequest to the TVD answers in 55% of the cases within 30ms with an average responsetime of 326ms. A database complex endpoint that also initiates a request to the TVDresponds in only 37% of the cases in less than 1000ms with an average response time of1017ms. An excerpt of the test results are shown in Figure 4.1.
Figure 4.1: Response Time Tests
According to Usability Engineering [10], requests that respond within less than 100msmake the user feel that the application is reacting instantaneously, meaning that no specialfeedback is necessary except to display the result. Any request that takes longer than1000ms needs a visual feedback to indicate that the system is busy with loading. This
4.2. USABILITY 27
applies to my database complex endpoints that also make a subsequent request to theTVD. Therefore, for every such request an activity indicator is prompted to the user.
28 CHAPTER 4. EVALUATION
Chapter 5
Summary and Conclusions
The predominant purpose of this Software Project was to design and implement a proto-typical system for simplifying the process of maintaining the cow paddock journal. Theresearch and analysis has shown that this manual maintainance of the journal is over-due to be replaced by a modern IT-solution. Therefore, the new system should reducebureaucracy and save costs.
To replace the current maintainance process the system needs some additional featuresand improvements:
• A feature that allows to filter and sort cows in various screens throughout the mobileapplication could improve the usability.
• In the case of sick or injured animals, one may derogate from the field lairageregulations [3]. Therefore, a feature that can add animals to a list of sick or injuredanimals and therefore automatically add a note in the cow paddock journal couldbe useful.
• Desktop computers are no foreign object in modernly equipped farms. Therefore, adesktop oder web application could be of great interest.
• As soon as electronic ear tags are available the system could become fully automated,meaning that the entry in the cow paddock journal are generated depending on thecows location throughout. The mobile application could still be used for monitoringthe progress of each animal.
Although, as long as the government does not expect farmers to maintain the cow paddockjournal for each cow separatly, this system will probably only arouse interest among thevery technologically enthusiastic farmers.
29
30 CHAPTER 5. SUMMARY AND CONCLUSIONS
Bibliography
[1] Maria Steinwender: Der Kuhohren-Flusterer, https://enorm-magazin.de/
der-kuhohren-fluesterer, n/a, accessed 24th of July 2017.
[2] Bundesamt fur Lebensmittelsicherheit und Veterinarwesen BLV: Auslauf furangebunden gehaltene Rinder, https://www.blv.admin.ch/blv/de/home/tiere/
tierschutz/nutztierhaltung/rinder/haltung-rind.html, 23rd of June 2016, ac-cessed 7th of August 2017.
[3] Der Schweizerische Bundesrat: Verordnung uber die Direktzahlungen an die Land-wirtschaft - Art. 75 Voraussetzungen fur RAUS-Beitrage, https://www.admin.
ch/opc/de/classified-compilation/20130216/index.html#a75, 23rd of October2013, accessed 7th of August 2017.
[4] Kanton Glarus: Direktzahlungen/Aufzeichnungsformulare, http://www.gl.ch/xml_1/internet/de/application/d1256/d37/d313/f1133.cfm, 2017, accessed 7th ofAugust 2017.
[5] Der Schweizerische Bundesrat: Verordnung uber die Direktzahlungen an dieLandwirtschaft - Chapter 1.1 Aufzeichnungen, https://www.admin.ch/opc/de/
classified-compilation/20130216/index.html#app1ahref2, 23rd of October2013, accessed 7th of August 2017.
[6] Der Schweizerische Bundesrat: Verordnung uber die Direktzahlungen andie Landwirtschaft - Art. 73 Tierkategorien, https://www.admin.ch/opc/de/
classified-compilation/20130216/index.html#a73, 23rd of October 2013, ac-cessed 7th of August 2017.
[7] Bundesamt fur Landwirtschaft BLW: Die Tierverkehrsdatenbank (TVD), https://www.agate.ch/portal/web/agate/die-tierverkehrsdatenbank-tvd/, 2017, ac-cessed 7th of August 2017.
[8] Chris Sevilleja: The Anatomy of a JSON Web Token, https://scotch.io/
tutorials/the-anatomy-of-a-json-web-token, 22nd of January 2015, accessed7th of August 2017.
[9] Emanuel Quimper: Testing your API with Postman, https://www.codementor.io/equimper/testing-your-api-with-postman-4tuwpkswp, 3rd of February 20017,accessed 7th of August 2017.
31
32 BIBLIOGRAPHY
[10] Jakob Nielsen: Response Times: The 3 Important Limits, https://www.nngroup.com/articles/response-times-3-important-limits/, 1st of January 1993, ac-cessed 7th of August 2017.
[11] JiyinYiyong: Virtual DOM is the new IR, https://medium.com/@jiyinyiyong/
virtual-dom-is-the-new-ir-67839bcb5c71, January 2016, accessed 7th of August2017.
[12] Christopher Chedeau: React’s diff algorithm, https://calendar.perfplanet.com/2013/diff/, 28th of December 2013, accessed 7th of August 2017.
[13] Simply: 6 Tips You Want to Know About React Native Per-formance, https://www.simplytechnologies.net/blog/2017/6/6/
6-tips-you-want-to-know-about-react-native-performance, 7th of June2017, accessed 7th of August 2017.
[14] Pete Heard: React Native Architecture : Explained!, https://www.logicroom.co/react-native-architecture-explained/, 1st of June 2013, accessed 7th of August2017.
[15] Tages Anzeiger: Bund will Strafen fur Bauernmildern, https://www.tagesanzeiger.ch/schweiz/standard/
Bund-will-Strafen-fuer-Bauern-mildern/story/30750084, 27th of April2017, accessed 7th of August 2017.
Abbreviations
REST Representational State TransferTVD TierverkehrsdatenbankJWT JSON Web TokenXML Extensible Markup LanguageDOM Document Object ModelUI User Interface
33
34 ABBREVIATONS
Glossary
TVD ”Tierverkehrsdatenbank” - a database maintaned by Identidas AG that allows re-traceablity of Swiss farm animals
Cow paddock journal ”Auslaufjournal” - a journal that records the field lairage of afarm. The responsible farmer registers which cows have spent the day outside.Maintaining this journal is a necessity if the farmer has subscriebed to the RAUSprogram.
Indentitas AG Swiss company that focuses on the registration and traceablity of Swissfarm animals
Smartbow Austrian company that manufactures electronic ear tag numbers for cowsthat allow real time localization.
Single sing-on Single sign-on (SSO) is a property of access control of multiple related,yet independent, software systems.
Direct payments ”Direktzahlungen”are payments from the government granted to farm-ers to ensure a basic income. The amount depends on many different conditions suchas the cow paddock journal.
Ethereum Ethereum is a public blockchain featuring the possibility of deploying smartcontracts. It also provides its own crypocurrency called ”Ether”.
Smart contracts Smart contracts are computer protocols that can make written fixationof a contract unnecessary. These protocols represent and review contracts. Theymay also technically support the negotiation or execution of the contract.
JSON Web Token (JWT) The JSON Web Token is a standard featuring the possibil-ity of transmitting information between two parties securely. The information canbe verified and trusted since it is digitally encrypted.
React Native React Native is open source framework created by Facebook. ReactNative lets you build mobile applications for Android as well as iOS using onlyJavaScript.
Agate Platform for Swiss farmers that is connected to the TVD for registering andmaintaining their animal stock.
Ether Ethers are the crypto-fuel for the Ethereum network.
35
36 GLOSSARY
List of Figures
1.1 Cow Paddock Journal [4] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 Relation between the aPayment system and the RAUS API . . . . . . . . . 7
2.2 Bridge between the Native Code and the JavaScript Runtime Environment 8
3.1 Dashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2 Menu Drawer for Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Date Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.4 Date Selection on different OS . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5 Type of Field Lairage Selection . . . . . . . . . . . . . . . . . . . . . . . . 20
3.6 Cow Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.7 Custom and Automatically Generated Categories Overview . . . . . . . . . 22
3.8 Custom Categories Can Be Edited . . . . . . . . . . . . . . . . . . . . . . 22
3.9 Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.10 Category Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1 Response Time Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
37
38 LIST OF FIGURES
List of Tables
3.1 Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Endpoints of the REST API . . . . . . . . . . . . . . . . . . . . . . . . . . 14
39
40 LIST OF TABLES
Appendix A
Installation Guidelines
A.1 Front End - ReactNative Application
A.1.1 Installation
After having set up React Native correctly run on the command prompt the followingcommands:
$ g i t c l one https : // github . com/ s imibac / raus mobi l e . g i t$ cd raus mobi l e /$ npm i n s t a l l$ react−nat ive l i n k
A.1.2 Simulate for iOS
Method One
• Open the project in Xcode from ios/raus_mobile.xcodeproj
• Hit the play button.
Method Two
• Run the following command in your terminal.
$ react−nat ive run−i o s
41
42 APPENDIX A. INSTALLATION GUIDELINES
A.1.3 Simulate for Android
Make sure you have an Android emulator installed and running. I use Genymotion An-droid Emulator.
• Run the following command in your terminal.
$ react−nat ive run−android
Appendix B
Contents of the CD
• abstract en.txt
English version of the abstract.
• abstract de.txt
German version of the abstract.
• raus mobile.zip
Source code of the React-Native mobile application (frontend).
• raus api.zip
Source code of the Golang backend.
• presentaion.pdf
The slides of the presentation.
• latex.zip
The LATEX source files for this thesis.
43