-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
185 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,41 @@ | ||
import { ModbusCommand } from './modbus-commands' | ||
|
||
export interface ModbusCommandFactory { | ||
export class ModbusCommandFactoryOptions { | ||
|
||
fromPacket(packet: Buffer): ModbusCommand<any> | ||
/** | ||
* If this option is set, the server will use 0 based coil, input status, and register addresses. | ||
* For instance, register 40001 will be 0, 40002 will be 1, etc. | ||
* | ||
* ``` | ||
* | | simple | modbus | | ||
* |------------------|--------|--------| | ||
* | Coil | 0 | 1 | | ||
* | Coil | 1 | 2 | | ||
* | Input | 0 | 10001 | | ||
* | Input | 1 | 10002 | | ||
* | Holding Register | 0 | 30001 | | ||
* | Holding Register | 1 | 30002 | | ||
* | Input Register | 0 | 40001 | | ||
* | Input Register | 1 | 40002 | | ||
* ``` | ||
* @default: true | ||
*/ | ||
simpleAddressing?: boolean | ||
|
||
} | ||
|
||
export abstract class ModbusCommandFactory { | ||
|
||
protected readonly simpleAddressing: boolean = true | ||
|
||
protected constructor(options?: ModbusCommandFactoryOptions) { | ||
if(options !== undefined){ | ||
if(options.simpleAddressing === false) { | ||
this.simpleAddressing = false | ||
} | ||
} | ||
} | ||
|
||
abstract fromPacket(packet: Buffer): ModbusCommand<any> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.