From 9291a5d1dbe9100aab07cc932ef804a86f857010 Mon Sep 17 00:00:00 2001 From: RubyOn Date: Wed, 23 Apr 2025 09:53:54 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B3=B5=EC=A1=B0=EA=B8=B0=20=EB=91=90?= =?UTF-8?q?=EA=B0=9C=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/controller.rb | 2 ++ db/migrate/20250423005211_create_controllers.rb | 7 +++++++ db/schema.rb | 11 +---------- test.rb | 12 ++++++++++++ test/fixtures/controllers.yml | 11 +++++++++++ test/models/controller_test.rb | 7 +++++++ 6 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 app/models/controller.rb create mode 100644 db/migrate/20250423005211_create_controllers.rb create mode 100644 test.rb create mode 100644 test/fixtures/controllers.yml create mode 100644 test/models/controller_test.rb diff --git a/app/models/controller.rb b/app/models/controller.rb new file mode 100644 index 0000000..654345f --- /dev/null +++ b/app/models/controller.rb @@ -0,0 +1,2 @@ +class Controller < ApplicationRecord +end diff --git a/db/migrate/20250423005211_create_controllers.rb b/db/migrate/20250423005211_create_controllers.rb new file mode 100644 index 0000000..c9909e1 --- /dev/null +++ b/db/migrate/20250423005211_create_controllers.rb @@ -0,0 +1,7 @@ +class CreateControllers < ActiveRecord::Migration[8.0] + def change + create_table :controllers do |t| + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index cab8406..0f651a4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,14 +10,5 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_04_16_131440) do - create_table "schedules", force: :cascade do |t| - t.integer "hour" - t.integer "minute" - t.boolean "is_active" - t.float "temperature" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["hour", "minute"], name: "index_schedules_on_hour_and_minute", unique: true - end +ActiveRecord::Schema[8.0].define(version: 0) do end diff --git a/test.rb b/test.rb new file mode 100644 index 0000000..5ea916a --- /dev/null +++ b/test.rb @@ -0,0 +1,12 @@ +require "rmodbus" +require "ccutrer-serialport" + +value = ARGV[0]&.to_i + +ModBus::RTUClient.new("/dev/ttyUSB0", 9600) do |cl| + cl.with_slave(7) do |slave| + regs = slave.holding_registers + regs[2] = value + sleep 0.1 + end +end diff --git a/test/fixtures/controllers.yml b/test/fixtures/controllers.yml new file mode 100644 index 0000000..d7a3329 --- /dev/null +++ b/test/fixtures/controllers.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the "{}" from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/controller_test.rb b/test/models/controller_test.rb new file mode 100644 index 0000000..c355ca7 --- /dev/null +++ b/test/models/controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class ControllerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end