공조기 두개 연결
This commit is contained in:
2
app/models/controller.rb
Normal file
2
app/models/controller.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Controller < ApplicationRecord
|
||||
end
|
||||
7
db/migrate/20250423005211_create_controllers.rb
Normal file
7
db/migrate/20250423005211_create_controllers.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class CreateControllers < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :controllers do |t|
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
11
db/schema.rb
generated
11
db/schema.rb
generated
@@ -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
|
||||
|
||||
12
test.rb
Normal file
12
test.rb
Normal file
@@ -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
|
||||
11
test/fixtures/controllers.yml
vendored
Normal file
11
test/fixtures/controllers.yml
vendored
Normal file
@@ -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
|
||||
7
test/models/controller_test.rb
Normal file
7
test/models/controller_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class ControllerTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user