コード例 #1
0
 /// <summary>
 /// 写设备
 /// </summary>
 /// <param name="interrupt_id">设备中断号</param>
 /// <param name="data">数据包</param>
 public override void DeviceWrite(int interrupt_id, byte[] data)
 {
     if (InterruptTables.TryGetValue(interrupt_id, out string label))
     {
         if (DeviceTables.TryGetValue(label, out DeviceTable table))
         {
             if (table.RunState)
             {
                 table.DevicePointer.Set(data);
             }
             else
             {
                 ControlInterrupt.Interrupt(DeviceException_Type.Not_Exist, table.Device_ID, table.DevicePointer);
             }
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// 读设备
 /// </summary>
 /// <param name="interrupt_id">设备中断号</param>
 /// <returns>返回数据</returns>
 public override byte[] DeviceRead(int interrupt_id)
 {
     if (InterruptTables.TryGetValue(interrupt_id, out string label))
     {
         if (DeviceTables.TryGetValue(label, out DeviceTable table))
         {
             if (table.RunState)
             {
                 return(table.DevicePointer.Get());
             }
             else
             {
                 ControlInterrupt.Interrupt(DeviceException_Type.Not_Exist, table.Device_ID, table.DevicePointer);
             }
         }
     }
     return(null);
 }