Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion imagenet-classification-for-raspi/.actdk/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
},
"raspberrypi-bullseye": {
"apt": [
"libraspberrypi0"
"libraspberrypi0",
"libatomic1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

たぶん関係ない

],
"pip": [
"actfw-raspberrypi"
Expand Down
15 changes: 15 additions & 0 deletions use-cache-volume/.actdk/dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"apt": [
"python3",
"python3-pil"
],
"pip": [],
"raspberrypi-bullseye": {
"apt": [
"libraspberrypi0"
],
"pip": [
"actfw-raspberrypi"
]
}
}
5 changes: 5 additions & 0 deletions use-cache-volume/.actdk/files.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"main": "main",
"healthchecker": "healthchecker",
"act_setting": "act_settings.json"
}
9 changes: 9 additions & 0 deletions use-cache-volume/.actdk/setting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"app_id": "use-cache-volume",
"app_server_id": 1,
"short_description": "example of using cache volume",
"short_descriptions": {},
"target_types": [
"raspberrypi-bullseye"
]
}
7 changes: 7 additions & 0 deletions use-cache-volume/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# use-cache-volume

**※このサンプルアプリケーションはActcastOS 3 に対応しています**

## 概要

マニフェストの`cache_volume`を指定することで、デバイス再起動後でも利用できるキャッシュボリュームを作成するサンプルアプリです。
1 change: 1 addition & 0 deletions use-cache-volume/act_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions use-cache-volume/app/healthchecker
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

true
3 changes: 3 additions & 0 deletions use-cache-volume/app/main
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exec python3 main.py
52 changes: 52 additions & 0 deletions use-cache-volume/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from time import sleep
import actfw_core
from actfw_core.task.task import Task
import subprocess

FILE_PATH = "/mnt/cache_volume/cachced_file"

class WritingFileTask(Task):
def __init__(self, interval):
super().__init__()
self.interval = interval

def run(self):
subprocess.run(["touch", FILE_PATH], check=True)
while self._is_running():
# read count from file
with open(FILE_PATH, "r") as f:
content = f.read()
actfw_core.notify([{ "message": content }])
if content == "":
count = 0
else:
count = int(content)

# overwrite count to file
with open(FILE_PATH, "w") as f:
f.write(str(count + 1))

# sleep
for i in range(self.interval):
if not self._is_running():
break
sleep(1)


def main():
# Actcast application
app = actfw_core.Application()

# Load act setting
settings = app.get_settings({ 'interval': 60 })

cmd = actfw_core.CommandServer()
actfw_core.notify([{ "message": "start up" }])

app.register_task(cmd)
app.register_task(WritingFileTask(settings.get('interval', 60)))

app.run()

if __name__ == "__main__":
main()
11 changes: 11 additions & 0 deletions use-cache-volume/data_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

{
"$schema": "https://actcast.io/schema/v8/data_schema_schema.json",
"type": "array",
"items": {
"type": "object",
"properties": {
},
"required": []
}
}
14 changes: 14 additions & 0 deletions use-cache-volume/manifesto/bullseye.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": 2,
"target_type": "raspberrypi-bullseye",
"boards": [
"RSPi3B",
"RSPi3BPlus",
"RSPi3APlus",
"RSPi4B"
],
"devices": [],
"cache_volume": {
"size": 16
}
}
12 changes: 12 additions & 0 deletions use-cache-volume/setting_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://actcast.io/schema/v8/setting_schema_schema.json",
"type": "object",
"properties": {
"interval": {
"type": "integer",
"minimum": 1,
"description": "Interval in seconds to count up"
}
},
"required": []
}