├── README.md ├── go.mod ├── pkg └── proto │ └── model │ ├── led.proto │ ├── button.proto │ ├── tick.proto │ └── dlr.proto ├── .gitignore ├── .github └── workflows │ └── create-issue.yaml ├── Makefile └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # op-proto 2 | OctopOS Prime Protocol Buffers 3 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/octoposprime/op-be-shared 2 | 3 | go 1.20 4 | -------------------------------------------------------------------------------- /pkg/proto/model/led.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option go_package = "github.com/octoposprime/op-proto/pkg/proto/pb/led"; 4 | 5 | message Led { 6 | 7 | LedState currentState = 1; 8 | 9 | } 10 | 11 | enum LedState { 12 | LED_STATE_OFF = 0; 13 | LED_STATE_ON = 1; 14 | } -------------------------------------------------------------------------------- /pkg/proto/model/button.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option go_package = "github.com/octoposprime/op-proto/pkg/proto/pb/button"; 4 | 5 | message Button { 6 | 7 | ButtonState currentState = 1; 8 | repeated ButtonState keyStates = 2; 9 | 10 | } 11 | 12 | enum ButtonState { 13 | BUTTON_STATE_OFF = 0; 14 | BUTTON_STATE_ON = 1; 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # If you prefer the allow list template instead of the deny list, see community template: 2 | # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore 3 | # 4 | # Binaries for programs and plugins 5 | *.exe 6 | *.exe~ 7 | *.dll 8 | *.so 9 | *.dylib 10 | 11 | # Test binary, built with `go test -c` 12 | *.test 13 | 14 | # Output of the go coverage tool, specifically when used with LiteIDE 15 | *.out 16 | 17 | # Dependency directories (remove the comment below to include it) 18 | # vendor/ 19 | 20 | # Go workspace file 21 | go.work 22 | -------------------------------------------------------------------------------- /pkg/proto/model/tick.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option go_package = "github.com/octoposprime/op-proto/pkg/proto/pb/tick"; 4 | 5 | message Tick { 6 | 7 | TickState currentState = 1; 8 | repeated TickState keyStates = 2; 9 | 10 | } 11 | 12 | message TickState { 13 | int64 value = 1; 14 | TickUnit unit = 2; 15 | } 16 | 17 | enum TickUnit { 18 | 19 | TICK_UNIT_UNSPECIFIED = 0; 20 | TICK_UNIT_SECOND = 1; 21 | TICK_UNIT_MINUTE = 2; 22 | TICK_UNIT_HOUR = 3; 23 | TICK_UNIT_DAY = 4; 24 | TICK_UNIT_WEEK = 5; 25 | TICK_UNIT_MONTH = 6; 26 | TICK_UNIT_YEAR = 7; 27 | 28 | } -------------------------------------------------------------------------------- /.github/workflows/create-issue.yaml: -------------------------------------------------------------------------------- 1 | name: Assign Project and Member 2 | on: 3 | issues: 4 | types: 5 | - opened 6 | jobs: 7 | label_issues: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | issues: write 11 | steps: 12 | - run: | 13 | gh issue edit "$NUMBER" --add-project "$PROJECT" --add-label "$TEAM_LABELS" --add-label "$FIRST_LABELS" 14 | env: 15 | GH_TOKEN: ${{ secrets.GH_TOKEN }} 16 | TEAM_LABELS: ${{ secrets.REPO_TEAM }} 17 | FIRST_LABELS: ${{ secrets.FIRST_ISSUE_LABELS }} 18 | GH_REPO: ${{ github.repository }} 19 | NUMBER: ${{ github.event.issue.number }} 20 | PROJECT: ${{ secrets.ASSIGN_PROJECT }} 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GREEN := $(shell tput -Txterm setaf 2) 2 | YELLOW := $(shell tput -Txterm setaf 3) 3 | WHITE := $(shell tput -Txterm setaf 7) 4 | CYAN := $(shell tput -Txterm setaf 6) 5 | RESET := $(shell tput -Txterm sgr0) 6 | 7 | .PHONY: all generate help 8 | 9 | all: help 10 | 11 | ## Generate: 12 | proto-generate: ## Protobuf Generate 13 | protoc -I=pkg/proto/model \ 14 | --go_out=../../../ \ 15 | --go-grpc_out=../../../ \ 16 | pkg/proto/model/tick.proto \ 17 | pkg/proto/model/led.proto \ 18 | pkg/proto/model/button.proto \ 19 | pkg/proto/model/dlr.proto \ 20 | --experimental_allow_proto3_optional 21 | 22 | ## Help: 23 | help: ## Show this help. 24 | @echo '' 25 | @echo 'Usage:' 26 | @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' 27 | @echo '' 28 | @echo 'Targets:' 29 | @awk 'BEGIN {FS = ":.*?## "} { \ 30 | if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \ 31 | else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \ 32 | }' $(MAKEFILE_LIST) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 octoposprime 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /pkg/proto/model/dlr.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option go_package = "github.com/octoposprime/op-proto/pkg/proto/pb/dlr"; 4 | import "tick.proto"; 5 | import "led.proto"; 6 | import "button.proto"; 7 | 8 | message Dlr { 9 | string id = 1; 10 | DlrHeader header = 2; 11 | DlrBody body = 3; 12 | } 13 | 14 | message DlrHeader { 15 | string id = 1; 16 | bool isRepeated = 2; 17 | optional string hookId = 3; 18 | } 19 | 20 | message DlrBody { 21 | string id = 1; 22 | DlrKey key = 2; 23 | repeated DlrComponent components = 3; 24 | repeated DlrCondition conditions = 4; 25 | } 26 | 27 | message DlrKey { 28 | string id = 1; 29 | oneof key { 30 | Tick tick = 10; 31 | Button button = 11; 32 | } 33 | } 34 | 35 | message DlrComponent { 36 | string id = 1; 37 | oneof component { 38 | Led led = 10; 39 | Button button = 11; 40 | } 41 | } 42 | 43 | message DlrCondition { 44 | string id = 1; 45 | repeated DlrConditionComponent components = 2; 46 | oneof keyState { 47 | TickState tickState = 10; 48 | ButtonState buttonState = 11; 49 | } 50 | } 51 | 52 | message DlrConditionComponent { 53 | string id = 1; 54 | oneof componentState { 55 | LedState ledState = 10; 56 | ButtonState buttonState = 11; 57 | } 58 | } --------------------------------------------------------------------------------