class ModbusController < ApplicationController def index @schedule = Schedule.all @modbus_running = Modbus::PollingService.running? end def start Modbus::PollingService.start redirect_to modbus_index_path end def stop Modbus::PollingService.stop redirect_to modbus_index_path end def schedule_edit @schedule = Schedule.all end def schedule_edit_update error_hours = [] params[:schedule].each do |id, attributes| schedule = Schedule.find_by(id: id) unless schedule.update(temperature: attributes[:temperature]) error_hours << "#{schedule.hour}시" end end if error_hours.any? redirect_to modbus_index_path, alert: "#{error_hours.join(', ')}의 온도 업데이트에 실패하였습니다." else redirect_to modbus_index_path, notice: "스케줄이 성공적으로 업데이트되었습니다." end end end