I need to register a custom error code while creating custom driver for Siebel CTI. As per its document, following errors are predefined (enum from scapi.h):
enum SCErrorCode
{
SC_EC_OK = 0,
SC_EC_ERROR = 1,
SC_EC_CMD_NOT_SUPPORTED = 2,
SC_EC_MEDIA_TYPE_NOT_SUPPORTED = 3,
SC_EC_INVALID_HANDLE = 4,
SC_EC_OUT_OF_MEMORY = 5,
SC_EC_NETWORK_ERROR = 6,
SC_EC_LIB_LOAD_ERR = 7, /* Unable to load driver DLL */
SC_EC_FUNC_NOT_RESOLVED = 8, /* Unable to resolve function address */
SC_EC_DRIVER_CREATION_ERR = 9,
SC_EC_DRIVER_RELEASE_ERR = 10,
SC_EC_SERVICE_CREATION_ERR = 11,
SC_EC_SERVICE_RELEASE_ERR = 12,
SC_EC_INVALID_ITEM_TRACKING_ID = 13,
SC_EC_CLIENT_INTERFACE_ERR = 14, /* Failed on invoking ISC_CLIENT_HANDLE function */
SC_EC_SENDMSG_FAILED_RETRY = 15, /* SC_CT_SENDMESSAGE failed, please resend again later */
SC_EC_IMPOBJ_CREATE_ERR = 16, /* Unable to create the underlying implementation object */
SC_EC_INVALID_LICENSE = 17,
SC_EC_WORK_ITEM_WRONG_STATE = 18, /* Work item is at wrong state for the operation */
SC_EC_DRIVER_SPECIFIC = 1000
};
Siebel Administration guide page 270 says:
SCErrorCode:
The values enumerated by SCErrorCode specify predefined error codes. The error codes from 0 to 1000 are reserved.
How can I add/register a custom error code? Or is there any way to specify driver specific error message using SC_EC_DRIVER_SPECIFIC error.
Related
By using the Godot engine and writing in the GDScript language,
let's say I have an enum declared as:
enum eTextMode {CHAR, NUMBER, SYMBOLS_TEXT, SYMBOLS_ALL}
And an export variable as:
export(eTextMode, FLAGS) var _id: int = 0
In the inspector panel I can see which flag is selected or not, but how can I know in code which specifically flag is selected?
By selecting in the inspector, for example: the NUMBER and SYMBOLS_TEXT flags, the _id variable will be set as 5
My approach is the following hard-coded dictionary:
var _selected_flags: Dictionary = {
CHAR = _id in [1, 3, 5, 7, 9, 11, 13, 15],
NUMBER = _id in [2, 3, 6, 7, 10, 11, 14, 15],
SYMBOLS_TEXT = _id in [4, 5, 6, 7, 12, 13, 14, 15],
SYMBOLS_ALL = _id in [8, 9, 10, 11, 12, 13, 14, 15]
}
Resulting in:
{CHAR:True, NUMBER:False, SYMBOLS_ALL:False, SYMBOLS_TEXT:True}
The above result is exactly what I'm expecting (a dictionary with string keys as they are defined in the enum with a boolean value representing the selection state).
How could I manage to do this dynamically for any enum regardless of size?
Thank you very much,
One tacky solution that I could manage is by not using an enum at all, but instead a dictionary like the following example:
const dTextMode: Dictionary = {CHAR = false, NUMBER = false, SYMBOLS_TEXT = false, SYMBOLS_ALL = false}
export(Dictionary) var m_dTextMode: Dictionary = dTextMode setget Set_TextMode, Get_TextMode
func Get_TextMode() -> Dictionary: return m_dTextMode
func Set_TextMode(_data: Dictionary = m_dTextMode) -> void: m_dTextMode = _data
An exported dictionary is not as good-looking as an exported enum with FLAGS, and by following this approach it kind of invalidates my initial problem.
By selecting CHAR and SYMBOLS_TEXT in the exported dictionary from the inspector, and then calling print(self.Get_TextMode()) the result is indeed what I expected:
{CHAR:True, NUMBER:False, SYMBOLS_ALL:False, SYMBOLS_TEXT:True}
I still can't figure out though how to achieve this result by using the export(*enum, FLAGS) aproach.
Edit: also, the setter function is not feasible to be used in script since the user must know to duplicate the dTextMode constant first, edit it and set is as an argument.
Thanks to the comments from #Thearot from my first answer, I have managed to figure out the following solution which meets all expectations, with one caveat: it seems like an overkill solution...
enum eTestFlags {FLAG_1, FLAG_2, FLAG_3, FLAG_5, FLAG_6}
export(eTestFlags, FLAGS) var m_iTestFlags: int = 0 setget Set_TestFlags
func Get_TestFlags() -> Dictionary: return self._get_enum_flags(m_iTestFlags, eTestFlags)
func Set_TestFlags(_id: int = m_iTestFlags) -> void: m_iTestFlags = _id
func _get_enum_flags(_val_selected: int, _enum: Dictionary, _bit_check_limit: int = 32) -> Dictionary:
var _enum_keys: Array = _enum.keys() ; _enum_keys.invert()
var _bin_string: String = ""
var _val_temp: int = 0
var _val_count: int = _bit_check_limit - int(_is_pow2(_bit_check_limit))
while(_val_count >= 0):
_val_temp = _val_selected >> _val_count
_bin_string += "1" if _val_temp & 1 else "0"
_val_count -= 1
var _bin_string_padded: String = "%0*d" % [_enum_keys.size(), int(_bin_string)]
var _result_dict: Dictionary = {}
for _str_id in range(_bin_string_padded.length(), 0, -1):
_result_dict[_enum_keys[_str_id - 1]] = bool(_bin_string_padded[_str_id - 1] == "1")
return _result_dict
func _is_pow2(_value: int) -> bool:
return _value && (not (_value & (_value - 1)))
Now, if I print(self.Get_TestFlags()) after selecting FLAG_2 and FLAG_6 the result is:
{FLAG_1:False, FLAG_2:True, FLAG_3:False, FLAG_5:False, FLAG_6:True}
You're on the right track but overcomplicating things. Without going too much into the math (see Wikipedia), here's what you'd do in Godot:
enum eTextMode {CHAR, NUMBER, SYMBOLS_TEXT, SYMBOLS_ALL}
export(eTextMode, FLAGS) var _id: int = 0
func _ready() -> void:
for modeName in eTextMode:
var bit_flag_value: int = int(pow(2, eTextMode[modeName]))
if _id & bit_flag_value:
printt("Flagged", modeName)
You can access the named fields of your enum like elements in an Array/Dictionary by default (iterate through the keys, get their 0-based index as values). The above math trick turns the 0-based index into the correct bit flag number, and if you (single) '&' it with the combined bit-flags value you can check whether or not that flag is set.
I'm making a c++ script and would like to add good looking icons to the gossip menu entries.
Where can I find the list?
The gossip list is available in the GossipDef.h file:
enum GossipOptionIcon
{
GOSSIP_ICON_CHAT = 0, // white chat bubble
GOSSIP_ICON_VENDOR = 1, // brown bag
GOSSIP_ICON_TAXI = 2, // flightmarker (paperplane)
GOSSIP_ICON_TRAINER = 3, // brown book (trainer)
GOSSIP_ICON_INTERACT_1 = 4, // golden interaction wheel
GOSSIP_ICON_INTERACT_2 = 5, // golden interaction wheel
GOSSIP_ICON_MONEY_BAG = 6, // brown bag (with gold coin in lower corner)
GOSSIP_ICON_TALK = 7, // white chat bubble (with "..." inside)
GOSSIP_ICON_TABARD = 8, // white tabard
GOSSIP_ICON_BATTLE = 9, // two crossed swords
GOSSIP_ICON_DOT = 10, // yellow dot/point
GOSSIP_ICON_CHAT_11 = 11, // white chat bubble
GOSSIP_ICON_CHAT_12 = 12, // white chat bubble
GOSSIP_ICON_CHAT_13 = 13, // white chat bubble
GOSSIP_ICON_UNK_14 = 14, // INVALID - DO NOT USE
GOSSIP_ICON_UNK_15 = 15, // INVALID - DO NOT USE
GOSSIP_ICON_CHAT_16 = 16, // white chat bubble
GOSSIP_ICON_CHAT_17 = 17, // white chat bubble
GOSSIP_ICON_CHAT_18 = 18, // white chat bubble
GOSSIP_ICON_CHAT_19 = 19, // white chat bubble
GOSSIP_ICON_CHAT_20 = 20, // white chat bubble
GOSSIP_ICON_MAX
};
Here is also an available list on the web wiki:
http://www.azerothcore.org/wiki/gossip_menu_option#optionicon
I have this current data structure on my firebase
{
"bible-operators": [{
"op-id": 0,
"op-name": "Anonymous",
"bcv": 101001001,
"op-version": 1,
"pass": "none",
"setting1": 1,
"setting2": 2,
"setting3": 3,
"setting4": 4,
"setting5": 5,
"setting6": 6,
"setting7": 7,
"bg": 1
}, ... {
"op-id": 4,
"op-name": "Test User 4",
"bcv": 101001001,
"op-version": 1,
"pass": "pass4",
"setting1": 1,
"setting2": 2,
"setting3": 3,
"setting4": 4,
"setting5": 5,
"setting6": 6,
"setting7": 7,
"bg": 1
}]
}
I tried to make test update using this function
function update(op_id, nuname, nuversion, nubcv, nupass) {
firebase.database().ref('operators/' + op_id).set({
"op-name": nuname,
"op-version": nuversion,
pass: nupass,
bcv : nubcv
});
}
My expected result is to update the provided new data but retain the others that has no updates. However, after calling update, all non provided data were deleted from the database. setting1-7 and bg.
How can I run the update without losing data that has no new data provided?
Thanks
The function firebase.database().ref('bible-operators/' + op_id).set() replace the document, you have to use update() instead of set().
try it:
firebase.database().ref('bible-operators/' + op_id).update({
"op-name": nuname,
"op-version": nuversion,
pass: nupass,
bcv : nubcv
});
I need to help to port my 3.5 rc.lua to 4.0. I try to set one progressbar.
It used to be :
mybacklight = awful.widget.progressbar()
mybacklight:set_width(12)
mybacklight:set_height(10)
mybacklight:set_vertical(true)
mybacklight:set_background_color("#131211")
mybacklight:set_border_color(nil)
The new version should be :
mybacklight = wibox.widget.progressbar {
max_value = 1,
value = brightness_new,
forced_width = 12,
forced_height = 10,
background_color = "#131211",
border_color = nil,
color = {type="linear", from = {0, 0}, to = {0, 20},
stops = { {0, "#F6F6F6"}, {0.5,
"#bdbdbd"}, {1.0, "#3b3b3b"} } },
widget = wibox.widget.progressbar,
direction = 'east',
layout = wibox.container.rotate
}
The 3.5 version works (no errors) but does no more give the expected result, it should be a vertical progressbar, it is, but the progression itself is horizontal.
The 4.0 version makes no error, except that it takes all the place with red (default ?) colors.
First of all, the imperative syntax isn't gone, you can still do it "the old way". It is fully supported and the declarative one is "compiled to" the old one.
Now, to answer the question, the code should look like (untested):
mybacklight = wibox.widget {
{
max_value = 1,
value = brightness_new,
background_color = "#131211",
color = {type="linear", from = {0, 0}, to = {0, 20},
stops = { {0, "#F6F6F6"}, {0.5,
"#bdbdbd"}, {1.0, "#3b3b3b"} }
},
widget = wibox.widget.progressbar,
},
forced_width = 12,
forced_height = 10,
direction = 'east',
layout = wibox.container.rotate
}
Changes:
The composite widget constructor is wibox.widget. You used the progressbar constructor to contruct a rotate container
Indentation to make the code more readable
You had 2 widget in the same block, this isn't supported.
Reference https://awesomewm.org/apidoc/classes/wibox.widget.progressbar.html#
In the below example would the queryable #q be evaluated a second time?
local(max = 10, m = 5)
local(q = with n in 1 to 10 select #n+#m)
#q // 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
if(true) => {
#q // is it invoke here like the above?
}
I suspect not, but if that's the case is it #q->asString that invokes the query?
I think you're right. Here's a simple test calling a counter thread object that increments on each call.
define test_count => thread {
data private val = 0
public asstring => {
.val += 1
return .val
}
}
local(max = 10, m = 5)
test_count
local(q = with n in 1 to 10 select #n+#m + integer(test_count -> asstring))
'<br />'
test_count
'<br />'
#q
'<br />'
test_count
'<br />'
if(true) => {
#q
}
'<br />'
test_count
Result ->
1
2
9, 11, 13, 15, 17, 19, 21, 23, 25, 27
13
14
The second call for #q is never processed. You can however force it to run by outputting it.