public void SetCommands(AdapterCommand commands) { if ((int)commands == 0) { return; } if ((commands & AdapterCommand.Select) == AdapterCommand.Select) { SqlBuilder.GetSelectCommand(this); } if (ReadOnly && commands != AdapterCommand.Select) { throw new ErrorOperationException("当前是只读状态,无法设置Insert/Update/Delete的Command", this); } if ((commands & AdapterCommand.Insert) == AdapterCommand.Insert) { SqlBuilder.GetInsertCommand(this); } if ((commands & AdapterCommand.Update) == AdapterCommand.Update) { SqlBuilder.GetUpdateCommand(this); } if ((commands & AdapterCommand.Delete) == AdapterCommand.Delete) { SqlBuilder.GetDeleteCommand(this); } fCommands = commands & (AdapterCommand.Insert | AdapterCommand.Update | AdapterCommand.Delete); }
public void RecvCommand(ushort commandWord) { // // Control of the adapter, ROS, and printer is accomplished with 16-bit commands. // The high-order 4 bits of the command give a command code; the remaining 12 bits are // used as an argument to the command. // _lastCommand = commandWord; AdapterCommand command = (AdapterCommand)(commandWord >> 12); int argument = commandWord & 0xfff; switch (command) { case AdapterCommand.BufferReset: break; case AdapterCommand.SetScales: _testMode = (argument & 0x1) != 0; _commandBeamOn = (argument & 0x2) != 0; _commandLocal = (argument & 0x4) != 0; _testPageSync = (argument & 0x8) != 0; _extendVideo = (argument & 0x20) != 0; _motorScale = (argument & 0x1c0) >> 6; _bitScale = (argument & 0xe00) >> 9; Log.Write(LogComponent.DoverROS, "TestMode {0} CommandBeamOn {1} CommandLocal {2} TestPageSync {3} ExtendVideo {4} MotorScale {5} BitScale {6}", _testMode, _commandBeamOn, _commandLocal, _testPageSync, _extendVideo, _motorScale, _bitScale); break; case AdapterCommand.SetBitClockRegister: _bitClock = argument; Log.Write(LogComponent.DoverROS, "BitClock set to {0}", argument); break; case AdapterCommand.SetMotorSpeedRegister: _motorSpeed = argument; Log.Write(LogComponent.DoverROS, "MotorSpeed set to {0}", argument); break; case AdapterCommand.SetLineSyncDelayRegister: _lineSyncDelay = argument; Log.Write(LogComponent.DoverROS, "LineSyncDelay set to {0}", argument); break; case AdapterCommand.SetPageSyncDelayRegister: _pageSyncDelay = argument; Log.Write(LogComponent.DoverROS, "PageSyncDelay set to {0}", argument); break; case AdapterCommand.ExternalCommand1: bool lastPrintRequest = (_externalCommand1 & 0x1) == 0; _externalCommand1 = argument; // // Dover uses the low-order bit to provide the PrintRequest signal. // A 0-to-1 transition of the bit tells the printer to start feeding // sheets. // Log.Write(LogComponent.DoverROS, "ExternalCommand1 written {0}", argument); if (lastPrintRequest && (_externalCommand1 & 0x1) != 0) { PrintRequest(); } break; case AdapterCommand.ExternalCommand2: _videoGate = argument; Log.Write(LogComponent.DoverROS, "VideoGate set to {0}", argument); break; default: Log.Write(LogType.Error, LogComponent.DoverROS, String.Format("Unhandled ROS command {0}", command)); break; } }