Vehicle life cycle
This network tracks the Lifecycle of Vehicles from manufacture to being scrapped involving private owners, manufacturers and scrap merchants. A regulator is able to provide oversight throughout this whole process.
This business network defines:
Participants AuctionHouse Company Manufacturer PrivateOwner Regulator ScrapMerchant
Assets Order Vehicle
Transactions PlaceOrder UpdateOrderStatus ApplicationForVehicleRegistrationCertificate PrivateVehicleTransfer ScrapVehicle UpdateSuspiciousScrapAllVehiclesByColour SetupDemo
Events PlaceOrderEvent UpdateOrderStatusEvent ScrapVehicleEvent
A PriavteOwner participant would submit a PlaceOrder transaction, through a Manufacturer's application. A Manufacturer would submit an UpdateOrderStatus transaction which would be the Vehicle being manufactured. They would apply for a registration certificate by submitting an ApplicationForVehicleRegistrationCertificate transaction. After the vehicle has been manufactured they would submit a PrivateVehicleTransfer transaction. A Regulator would be able perform oversight over this whole process and submit an UpdateSuspicious transaction to view any suspicious vehicles that may be out of compliance with regulations. A ScrapMerchant would be able to submit a ScrapVehicle or a ScrapAllVehiclesByColour transaction to complete the lifecycle of a vehicle.
composer-sample-networks/packages/vehicle-lifecycle-network at master · hyperledger-archives/composer-sample-networks
GitHub
1
archetype vehicle_lifecycle
2
3
asset owner {
4
ido : role;
5
fn : string;
6
ln : string;
7
}
8
9
enum order_state =
10
| Placed initial
11
| Scheduled_for_manufacture
12
| Vin_assigned
13
| Owner_assigned
14
| Delivered
15
16
asset vehicledetail {
17
idv : string;
18
dcolor : string;
19
}
20
21
asset manufacturer {
22
mid : string;
23
}
24
25
asset order {
26
oid : string;
27
amanufacturer : pkey<manufacturer>;
28
orderer : pkey<owner>;
29
details : pkey<vehicledetail>;
30
} with states order_state
31
32
enum vehicle_state =
33
| Off_the_road
34
| Active
35
| Scrapped
36
37
asset vehicle identified by vin {
38
vin : string;
39
aowner : pkey<owner>;
40
detail : pkey<vehicledetail>;
41
color : string;
42
vstate : vehicle_state = Off_the_road;
43
}
44
45
entry placeOrder (iid : string,
46
imanufacturer : pkey<manufacturer>,
47
iorderer : pkey<owner>,
48
idetails : pkey<vehicledetail>) {
49
called by iorderer
50
effect {
51
order.add({ iid; imanufacturer; iorderer; idetails})
52
}
53
}
54
55
transition assign_vin (avin : string, adetail : pkey<vehicledetail>) on (ok : pkey<order>) {
56
called by order[ok].orderer
57
58
from Placed
59
to Vin_assigned
60
with effect {
61
vehicle.add ({ vin = avin; aowner = order[ok].orderer; detail = adetail; color = vehicledetail[adetail].dcolor })
62
}
63
}
64
65
transition assign_owner () on (ok : pkey<order>) {
66
from any
67
to Owner_assigned
68
with effect {
69
(* set vehicle state *)
70
vehicle[vehicledetail[order[ok].details].idv].vstate := Active;
71
}
72
}
73
74
entry vehicleTransfer (buyer : pkey<owner>, vk : pkey<vehicle>) {
75
called by vehicle[vk].aowner
76
effect {
77
vehicle[vk].aowner := buyer
78
}
79
}
80
81
entry scrapVehicle (vk : pkey<vehicle>) {
82
called by vehicle[vk].aowner
83
require {
84
r1: vehicle[vk].vstate = Off_the_road or vehicle[vk].vstate = Active
85
}
86
effect {
87
vehicle[vk].vstate := Scrapped
88
}
89
}
90
91
entry scrapVehiclebyColor (acolor : string) {
92
effect {
93
for v in vehicle.select(color = acolor) do
94
vehicle[v].vstate := Scrapped
95
done
96
}
97
}
98
Copied!
Last modified 1yr ago
Export as PDF
Copy link
Edit on GitHub