The files contained in this repository can be downloaded to your computer using a svn client.
On Linux you simply type the command displayed below.
This URL has Read-Only access.
root / trunk / DomotiGa / FSettingsCTX35.class @ 853
History | View | Annotate | Download (2.7 kB)
| 1 | ' Gambas class file |
|---|---|
| 2 | |
| 3 | ' Description: |
| 4 | ' FSettingsCTX35.class |
| 5 | ' Settings form for Xanura CTX35 A10/X10 interface. |
| 6 | |
| 7 | ' Development Status: |
| 8 | ' Works. |
| 9 | |
| 10 | ' DomotiGa - an open source home automation program. |
| 11 | ' Copyright(C) 2008-2009 Ron Klinkien |
| 12 | |
| 13 | ' Read file called COPYING for license details. |
| 14 | |
| 15 | PUBLIC SUB Form_Open() |
| 16 | |
| 17 | ME.Move(FMain.X + 50, FMain.Y + 70) |
| 18 | |
| 19 | txtSerialPort.Text = Main.sCTX35SerialPort |
| 20 | cmbBaudrate.Text = Main.sCTX35Baudrate |
| 21 | txtPollTime.Text = Main.iCTX35PollTime |
| 22 | chkDebug.Value = Main.bCTX35Debug |
| 23 | chkEnabled.Value = Main.bCTX35Enabled |
| 24 | chkGlobalX10.Value = Main.bCTX35GlobalX10 |
| 25 | btnSave.Enabled = FALSE |
| 26 | |
| 27 | IF Main.bCTX35Enabled = FALSE THEN |
| 28 | txtSerialPort.Enabled = FALSE |
| 29 | cmbBaudrate.Enabled = FALSE |
| 30 | txtPollTime.Enabled = FALSE |
| 31 | chkGlobalX10.Enabled = FALSE |
| 32 | chkDebug.Enabled = FALSE |
| 33 | ENDIF |
| 34 | |
| 35 | END |
| 36 | |
| 37 | PUBLIC SUB btnCancel_Click() |
| 38 | |
| 39 | ME.Close |
| 40 | |
| 41 | END |
| 42 | |
| 43 | PUBLIC SUB txtSerialPort_KeyPress() |
| 44 | |
| 45 | btnSave.Enabled = TRUE |
| 46 | |
| 47 | END |
| 48 | |
| 49 | PUBLIC SUB cmbBaudrate_Click() |
| 50 | |
| 51 | btnSave.Enabled = TRUE |
| 52 | |
| 53 | END |
| 54 | |
| 55 | PUBLIC SUB txtPollTime_KeyPress() |
| 56 | |
| 57 | btnSave.Enabled = TRUE |
| 58 | |
| 59 | END |
| 60 | |
| 61 | PUBLIC SUB chkGlobalX10_Click() |
| 62 | |
| 63 | btnSave.Enabled = TRUE |
| 64 | |
| 65 | END |
| 66 | |
| 67 | PUBLIC SUB chkDebug_Click() |
| 68 | |
| 69 | btnSave.Enabled = TRUE |
| 70 | |
| 71 | END |
| 72 | |
| 73 | PUBLIC SUB btnSave_Click() |
| 74 | |
| 75 | DIM rResult AS Result |
| 76 | |
| 77 | ' save new CTX35 settings |
| 78 | rResult = Main.hDB.Exec("UPDATE settings_ctx35 SET debug = &1, polltime = &2, serialport = &3, baudrate = &4, globalx10 = &5, enabled = &6 WHERE id = 1", chkDebug.Value, txtPollTime.Text, txtSerialPort.Text, cmbBaudrate.Text, chkGlobalX10.Value, chkEnabled.Value)
|
| 79 | rResult = Main.GetSettingTable("ctx35") ' reload settings
|
| 80 | IF rResult.Count THEN |
| 81 | Main.bCTX35Enabled = rResult!enabled |
| 82 | Main.sCTX35SerialPort = rResult!serialport |
| 83 | Main.sCTX35Baudrate = rResult!baudrate |
| 84 | Main.iCTX35PollTime = rResult!polltime |
| 85 | Main.bCTX35GlobalX10 = rResult!globalx10 |
| 86 | Main.bCTX35Debug = rResult!debug |
| 87 | ENDIF |
| 88 | IF Main.bServer THEN |
| 89 | Main.Restart_CTX35() |
| 90 | ELSE |
| 91 | XMLClient.ModuleRestart("CTX35")
|
| 92 | ENDIF |
| 93 | FMain.UpdateStatusPanel() |
| 94 | ME.Close |
| 95 | |
| 96 | END |
| 97 | |
| 98 | PUBLIC SUB btnDefaults_Click() |
| 99 | |
| 100 | DIM rResult AS Result |
| 101 | |
| 102 | rResult = Main.GetSettingTable("ctx35", TRUE) ' get defaults
|
| 103 | IF rResult.Count THEN |
| 104 | chkEnabled.Value = rResult!enabled |
| 105 | txtSerialPort.Text = rResult!serialport |
| 106 | txtPollTime.Text = rResult!polltime |
| 107 | cmbBaudrate.Text = rResult!baudrate |
| 108 | chkGlobalX10.Value = rResult!globalx10 |
| 109 | chkDebug.Value = rResult!debug |
| 110 | ENDIF |
| 111 | btnSave.Enabled = TRUE |
| 112 | |
| 113 | END |
| 114 | |
| 115 | PUBLIC SUB chkEnabled_Click() |
| 116 | |
| 117 | txtSerialPort.Enabled = chkEnabled.Value |
| 118 | cmbBaudrate.Enabled = chkEnabled.Value |
| 119 | txtPollTime.Enabled = chkEnabled.Value |
| 120 | chkGlobalX10.Enabled = chkEnabled.Value |
| 121 | chkDebug.Enabled = chkEnabled.Value |
| 122 | btnSave.Enabled = TRUE |
| 123 | |
| 124 | END |
