cgminerstatus.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. --[[
  2. LuCI - Lua Configuration Interface
  3. Copyright 2014 Fengling <Fengling.Qin@gmail.com>
  4. Copyright 2013 Xiangfu
  5. Copyright 2008 Steven Barth <steven@midlink.org>
  6. Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
  7. Licensed under the Apache License, Version 2.0 (the "License");
  8. you may not use this file except in compliance with the License.
  9. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. $Id$
  12. ]]--
  13. btnref = luci.dispatcher.build_url("admin", "status", "cgminerstatus", "restart")
  14. f = SimpleForm("cgminerstatus", translate("Cgminer Status") ..
  15. " <input type=\"button\" value=\" " .. translate("Restart Cgminer") .. " \" onclick=\"location.href='" .. btnref .. "'\" href=\"#\"/>",
  16. translate(""..
  17. ""))
  18. f.reset = false
  19. f.submit = false
  20. t = f:section(Table, luci.controller.cgminer.summary(), translate("Summary"))
  21. t:option(DummyValue, "elapsed", translate("Elapsed"))
  22. ghsav = t:option(DummyValue, "mhsav", translate("GHSav"))
  23. function ghsav.cfgvalue(self, section)
  24. local v = Value.cfgvalue(self, section):gsub(",","")
  25. return string.format("%.2f", tonumber(v)/1000)
  26. end
  27. t:option(DummyValue, "accepted", translate("Accepted"))
  28. t:option(DummyValue, "rejected", translate("Rejected"))
  29. t:option(DummyValue, "networkblocks", translate("NetworkBlocks"))
  30. t:option(DummyValue, "bestshare", translate("BestShare"))
  31. t2 = f:section(Table, luci.controller.cgminer.pools(), translate("Pools"))
  32. t2:option(DummyValue, "pool", translate("Pool"))
  33. t2:option(DummyValue, "url", translate("URL"))
  34. t2:option(DummyValue, "stratumactive", translate("StratumActive"))
  35. t2:option(DummyValue, "user", translate("User"))
  36. t2:option(DummyValue, "status", translate("Status"))
  37. t2:option(DummyValue, "stratumdifficulty", translate("StratumDifficulty"))
  38. t2:option(DummyValue, "getworks", translate("GetWorks"))
  39. t2:option(DummyValue, "accepted", translate("Accepted"))
  40. t2:option(DummyValue, "rejected", translate("Rejected"))
  41. t2:option(DummyValue, "stale", translate("Stale"))
  42. t2:option(DummyValue, "lastsharetime", translate("LST"))
  43. t2:option(DummyValue, "lastsharedifficulty", translate("LSD"))
  44. t1 = f:section(Table, luci.controller.cgminer.devs(), translate("Devices"))
  45. t1:option(DummyValue, "name", translate("Device"))
  46. t1:option(DummyValue, "enable", translate("Enabled"))
  47. t1:option(DummyValue, "status", translate("Status"))
  48. t1:option(DummyValue, "temp", translate("Temperature(C)"))
  49. ghsav = t1:option(DummyValue, "mhsav", translate("GHSav"))
  50. function ghsav.cfgvalue(self, section)
  51. local v = Value.cfgvalue(self, section)
  52. return string.format("%.2f", v/1000)
  53. end
  54. ghs5s = t1:option(DummyValue, "mhs5s", translate("GHS5s"))
  55. function ghs5s.cfgvalue(self, section)
  56. local v = Value.cfgvalue(self, section)
  57. return string.format("%.2f", v/1000)
  58. end
  59. ghs1m = t1:option(DummyValue, "mhs1m", translate("GHS1m"))
  60. function ghs1m.cfgvalue(self, section)
  61. local v = Value.cfgvalue(self, section)
  62. return string.format("%.2f", v/1000)
  63. end
  64. ghs5m = t1:option(DummyValue, "mhs5m", translate("GHS5m"))
  65. function ghs5m.cfgvalue(self, section)
  66. local v = Value.cfgvalue(self, section)
  67. return string.format("%.2f", v/1000)
  68. end
  69. ghs15m = t1:option(DummyValue, "mhs15m", translate("GHS15m"))
  70. function ghs15m.cfgvalue(self, section)
  71. local v = Value.cfgvalue(self, section)
  72. return string.format("%.2f", v/1000)
  73. end
  74. t1:option(DummyValue, "lvw", translate("LastValidWork"))
  75. local stats = luci.controller.cgminer.stats()
  76. t1 = f:section(Table, stats, translate("Devices Status"))
  77. indicator = t1:option(Button, "_indicator", translate("Indicator"))
  78. function indicator.render(self, section, scope)
  79. if stats[section].led == '0' then
  80. self.title = translate("LED OFF")
  81. else
  82. self.title = translate("LED ON")
  83. end
  84. Button.render(self, section, scope)
  85. end
  86. function indicator.write(self, section)
  87. cmd = "/usr/bin/cgminer-api " .. "\'ascset|" .. stats[section].devid .. ',led,' .. stats[section].moduleid .. "\'"
  88. luci.util.execi(cmd)
  89. if stats[section].led == '0' then
  90. stats[section].led = '1'
  91. else
  92. stats[section].led = '0'
  93. end
  94. end
  95. t1:option(DummyValue, "elapsed", translate("Elapsed"))
  96. t1:option(DummyValue, "id", translate("Device"))
  97. t1:option(DummyValue, "mm", translate("MM"))
  98. t1:option(DummyValue, "dna", translate("DNA"))
  99. t1:option(DummyValue, "lw", translate("LocalWorks"))
  100. t1:option(DummyValue, "ss", translate("SmartSpeed"))
  101. t1:option(DummyValue, "ghsmm", translate("GHS"))
  102. t1:option(DummyValue, "temp", translate("Temperature(C)"))
  103. t1:option(DummyValue, "fan", translate("Fan(RPM)"))
  104. t1:option(DummyValue, "voltage", translate("InputVoltage(V)"))
  105. t1:option(DummyValue, "pg", translate("PG"))
  106. t1:option(DummyValue, "ec", translate("EC"))
  107. return f