diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7081c25 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +[*.d] +dfmt_align_switch_statements = true +# allman, otbs, or stroustrup +dfmt_brace_style = otbs +#dfmt_brace_style = stroustrup +dfmt_outdent_attributes = true +dfmt_outdent_labels = true +dfmt_soft_max_line_length = 80 +dfmt_space_after_cast = false +dfmt_space_after_keywords = true +dfmt_split_operator_at_line_end = false + +trim_trailing_whitespace = true +end_of_line = lf +indent_size = 3 +indent_style = space +insert_final_newline = true +max_line_length = 120 +tab_width = 8 diff --git a/examples/timerc/dub.sdl b/examples/timerc/dub.sdl new file mode 100644 index 0000000..e3a7ddb --- /dev/null +++ b/examples/timerc/dub.sdl @@ -0,0 +1,12 @@ +name "timer" +description "Simple timer example" +authors "Orfeo Da Viá" +copyright "Copyright © 2017, o3o" +license "LGPL v3.0.0" +dependency "dinodave" path="../../" + +targetType "executable" +targetPath "bin" +libs "nodave" platform="posix" +sourceFiles "../../lib/libnodave.lib" platform="windows-x86_32-dmd" +copyFiles "../../lib/libnodave.dll" platform="windows-x86_32-dmd" diff --git a/examples/timerc/src/app.d b/examples/timerc/src/app.d new file mode 100644 index 0000000..49be041 --- /dev/null +++ b/examples/timerc/src/app.d @@ -0,0 +1,34 @@ +import std.stdio; +import std.conv; + +import dinodave; + +void main(string[] args) { + enum string IP = "192.168.0.150"; + string ip = IP; + if (args.length > 1) { + ip = args[1]; + } + + writeln("Use ip ", ip); + writeln("\nTrying to read 4 items from Timers (supposed to work S7-3xx/4xx)\n"); + auto dc = createConnection(ip); + // read 4 timers: each timer has 2 bytes + const(int) res = daveReadBytes(dc, daveTimer, 0, 0, 4, null); + + writefln("function result:%d=%s\n", res, daveStrerror(res)); + + if (res == 0) { + writeln("\nShowing the results using daveGetSeconds(dc)\n"); + writefln("Time: %0.3f, ", daveGetSeconds(dc)); + writefln("%0.3f, ", daveGetSeconds(dc)); + writefln("%0.3f, ", daveGetSeconds(dc)); + writefln(" %0.3f\n", daveGetSeconds(dc)); + + writeln("\nShowing the same results using daveGetSecondsAt(dc,position)\n"); + writefln("Time: %0.3f, ", daveGetSecondsAt(dc, 0)); + writefln("%0.3f, ", daveGetSecondsAt(dc, 2)); + writefln("%0.3f, ", daveGetSecondsAt(dc, 4)); + writefln(" %0.3f\n", daveGetSecondsAt(dc, 6)); + } +}