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.

Statistics
| Revision:

root / trunk / DomotiGa / FSettingsDSC.class @ 547

History | View | Annotate | Download (3.2 kB)

1
' Gambas class file
2
3
' Description:
4
' FSettingsDSC.class
5
' Settings form for DSC Security support.
6
7
' Development Status:
8
' Alpha.
9
10
' DomotiGa - an open source home automation program.
11
' Copyright(C) 2009 Ron Klinkien
12
' This module is written by and Copyright(C) 2009 Timo Sariwating
13
14
' Read file called COPYING for license details.
15
16
PUBLIC SUB Form_Open()
17
18
  ME.Move(FMain.X + 50, FMain.Y + 70)
19
20
  txtSerialPort.Text = Main.sDSCSerialPort
21
  cmbBaudrate.Text = Main.sDSCBaudrate
22
  chkDebug.Value = Main.bDSCDebug
23
  chkEnabled.Value = Main.bDSCEnabled
24
  btnSave.Enabled = FALSE
25
26
  IF Main.bDSCEnabled = FALSE THEN
27
    txtSerialPort.Enabled = FALSE
28
    cmbBaudrate.Enabled = FALSE
29
    chkDebug.Enabled = FALSE
30
    btnSend_Time.Enabled = FALSE
31
    btnArm_Stay.Enabled = FALSE
32
    btnArm_Away.Enabled = FALSE
33
  END IF
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 chkDebug_Click()
56
57
  btnSave.Enabled = TRUE
58
59
END
60
61
PUBLIC SUB btnSave_Click()
62
63
  DIM rResult AS Result
64
65
  ' save new DSC Security settings
66
  rResult = Main.hDB.Exec("UPDATE settings_dsc SET debug = &1, serialport = &2, baudrate = &3, enabled = &4 WHERE id = 1", chkDebug.Value, txtSerialPort.Text, cmbBaudrate.Text, chkEnabled.Value)
67
  rResult = Main.GetSettingTable("dsc") ' reload settings
68
  IF rResult.Count THEN
69
    Main.bDSCEnabled = rResult!enabled
70
    Main.sDSCSerialPort = rResult!serialport
71
    Main.sDSCBaudrate = rResult!baudrate
72
    Main.bDSCDebug = rResult!debug
73
  END IF
74
  IF Main.bServer THEN
75
    Main.Restart_DSC()
76
  ELSE
77
    XMLClient.ModuleRestart("DSC")
78
  END IF
79
  FMain.UpdateStatusPanel()
80
  ME.Close
81
82
END
83
84
PUBLIC SUB btnDefaults_Click()
85
86
  DIM rResult AS Result
87
88
  rResult = Main.GetSettingTable("dsc", TRUE) ' get defaults
89
  IF rResult.Count THEN
90
    chkEnabled.Value = rResult!enabled
91
    txtSerialPort.text = rResult!serialport
92
    cmbBaudrate.text = rResult!baudrate
93
    chkDebug.Value = rResult!debug
94
  END IF
95
  btnSave.Enabled = TRUE
96
97
END
98
99
PUBLIC SUB chkEnabled_Click()
100
101
  txtSerialPort.Enabled = chkEnabled.Value
102
  cmbBaudrate.Enabled = chkEnabled.Value
103
  chkDebug.Enabled = chkEnabled.Value
104
  btnSend_Time.Enabled = chkEnabled.Value
105
  btnArm_Stay.Enabled = chkEnabled.Value
106
  btnArm_Away.Enabled = chkEnabled.Value
107
  btnSave.Enabled = TRUE
108
109
END
110
111
PUBLIC SUB btnArm_Stay_Click()
112
113
  IF Main.bServer AND IF Main.hDSC THEN
114
    Main.hDSC.TX("0311")
115
  ELSE IF Main.bDSCEnabled THEN
116
    XMLClient.SetAlarmMode("0311")
117
  ELSE
118
    Main.WriteDebugLog(("[DSC] Connection with alarm system not enabled yet."))
119
  END IF
120
121
END
122
123
PUBLIC SUB btnSend_Time_Click()
124
125
  DIM sTime_Now AS String
126
127
  sTime_Now = "010" & Format$(Now, "hhnnmmddyy")
128
  IF Main.bServer AND IF Main.hDSC THEN
129
    Main.hDSC.TX(sTime_Now)
130
    Main.WriteDebugLog(("[DSC] System time set to ") & Now & (" on alarm system"))
131
  ELSE
132
    Main.WriteDebugLog(("[DSC] Connection with alarm system not enabled yet."))
133
  END IF
134
135
END
136
137
PUBLIC SUB btnArm_Away_Click()
138
139
  IF Main.bServer AND IF Main.hDSC THEN
140
    Main.hDSC.TX("0301")
141
  ELSE IF Main.bDSCEnabled THEN
142
    XMLClient.SetAlarmMode("0301")
143
  ELSE
144
    Main.WriteDebugLog(("[DSC] Connection with alarm system not enabled yet."))
145
  END IF
146
147
END