public ERROR_ID SoftReset() { RBA_API.SetParam(PARAMETER_ID.P15_REQ_RESET_TYPE, "9"); ERROR_ID result = RBA_API.ProcessMessage(MESSAGE_ID.M15_SOFT_RESET); return(result); }
public string Connect(string port, LogHandler traceLog, IngenicoLoggingLevel logLevel) { //RBA_API.logHandler = new LogHandler(traceLog); //RBA_API.SetDefaultLogLevel((LOG_LEVEL)logLevel); RBA_API.Initialize(); //RBA_API.SetNotifyRbaDisconnected(new DisconnectHandler(DeviceConnectionEvent)); //RBA_API.pinpadHandler = new PinPadMessageHandler(pinpadHandler); ERROR_ID result = SetDeviceCommunications(port); //set configuration for on demand //TODO - make this configuration driven SetDeviceToOnDemand(); SoftReset(); if (result.ToString().Contains("SUCCESS") || result.ToString().Contains("RESULT_ERROR_ALREADY_CONNECTED")) { Connected = true; //make sure Encryption is on //if (!IsEncryptionOn(CheckKeys())) //{ // Connected = false; //} } return(result.ToString()); }
public ERROR_ID UpdateDevice(string formFilePath) { string filename = Path.GetFileName(formFilePath); RBA_API.SetParam(PARAMETER_ID.P62_REQ_RECORD_TYPE, "0"); RBA_API.SetParam(PARAMETER_ID.P62_REQ_ENCODING_FORMAT, "8"); //this will be a tgz file for all forms - application files are set to 1 if (formFilePath.ToLower().Contains("ogz")) { RBA_API.SetParam(PARAMETER_ID.P62_REQ_UNPACK_FLAG, "0"); } else { RBA_API.SetParam(PARAMETER_ID.P62_REQ_UNPACK_FLAG, "1"); } RBA_API.SetParam(PARAMETER_ID.P62_REQ_FAST_DOWNLOAD, "1"); RBA_API.SetParam(PARAMETER_ID.P62_REQ_OS_FILE_NAME, formFilePath); RBA_API.SetParam(PARAMETER_ID.P62_REQ_FILE_NAME, filename); ERROR_ID result = RBA_API.ProcessMessage(MESSAGE_ID.FILE_WRITE); return(result); }
private ERROR_ID SetDeviceCommunications(string port) { SETTINGS_COMMUNICATION commSet = new SETTINGS_COMMUNICATION(); SETTINGS_COMM_TIMEOUTS commTimeouts; uint connectTimeout = 5000; commTimeouts.ConnectTimeout = connectTimeout; commTimeouts.ReceiveTimeout = connectTimeout; commTimeouts.SendTimeout = connectTimeout; RBA_API.SetCommTimeouts(commTimeouts); commSet.interface_id = (uint)COMM_INTERFACE.SERIAL_INTERFACE; commSet.rs232_config.ComPort = port; commSet.rs232_config.BaudRate = Convert.ToUInt32(ComBaudRate); commSet.rs232_config.DataBits = Convert.ToUInt32(ComDataBits); commSet.rs232_config.Parity = (uint)0; commSet.rs232_config.StopBits = Convert.ToUInt32(1); commSet.rs232_config.FlowControl = (uint)0; //Connect to pin pad ERROR_ID result = RBA_API.Connect(commSet); return(result); }
public ERROR_ID WriteConfiguration(string group, string index, string data) { RBA_API.SetParam(PARAMETER_ID.P60_REQ_GROUP_NUM, group); RBA_API.SetParam(PARAMETER_ID.P60_REQ_INDEX_NUM, index); RBA_API.SetParam(PARAMETER_ID.P60_REQ_DATA_CONFIG_PARAM, data); ERROR_ID result = RBA_API.ProcessMessage(MESSAGE_ID.M60_CONFIGURATION_WRITE); return(result); }
public string RetrieveFile(string filename) { RBA_API.SetParam(PARAMETER_ID.P65_REQ_RECORD_TYPE, "1"); //dataformat - 0 = plain text and 1 = BASE64 Format - all should be plain text 0 RBA_API.SetParam(PARAMETER_ID.P65_REQ_DATA_TYPE, "0"); RBA_API.SetParam(PARAMETER_ID.P65_REQ_FILE_NAME, filename); ERROR_ID result = RBA_API.ProcessMessage(MESSAGE_ID.M65_RETRIVE_FILE); //get value that will determine is the file was actually found and retreived string resultMessage = RBA_API.GetParam(PARAMETER_ID.P65_RES_RESULT); string fileData = RBA_API.GetParam(PARAMETER_ID.P65_RES_DATA); return(fileData); }
public void Set24RebootTime(string action) { //check device configuration //this will pull the requested file from the device and store in the application executing directory //DataFormats 0 = plain text / 1 = Base64 format try { string file_path = @"/HOST/MANAGER.DIA"; string result = RetrieveFile(file_path); //parse Manager.DIA file - ; delimited list List <string> managerDia = new List <string>(); //clean up the data result = result.Replace("\r\n", ""); managerDia.AddRange(result.Split(';')); string rebootConfig = managerDia.FirstOrDefault(m => m.Contains("020649")); if (!string.IsNullOrWhiteSpace(rebootConfig)) { string rebootValue = rebootConfig.Split('=')[1]; if (rebootValue == "1") { string path = System.Reflection.Assembly.GetExecutingAssembly().Location; var directory = System.IO.Path.GetDirectoryName(path); ERROR_ID updateResult = UpdateDevice(Path.Combine(directory, "Resources", Path.GetFileName("MANAGER.PAR"))); if (updateResult != ERROR_ID.RESULT_SUCCESS) { OnNotification(this, new NotificationEventArgs { NotificationType = NotificationType.Log, Message = $"Not able to load MANAGER.PAR file to the device.{ Environment.NewLine }" }); } } } //reconfigure device with configuration setting SetRebootTime(action); } catch (Exception ex) { OnNotification(this, new NotificationEventArgs { NotificationType = NotificationType.Log, Message = $"Error getting file from device {ex.Message}{Environment.NewLine}" }); } }
public ERROR_ID UpdateDeviceCustom(string form_file_path) { ERROR_ID Result = ERROR_ID.RESULT_SUCCESS; try { string filename = Path.GetFileName(form_file_path); Result = RBA_API.SetParam(PARAMETER_ID.P62_REQ_UNPACK_FLAG, "0"); Result = RBA_API.SetParam(PARAMETER_ID.P62_REQ_ENCODING_FORMAT, "8"); //this will be a tgz file for all forms - application files are set to 1 if (form_file_path.ToLower().Contains("ogz")) { Result = RBA_API.SetParam(PARAMETER_ID.P62_REQ_UNPACK_FLAG, "0"); } else { Result = RBA_API.SetParam(PARAMETER_ID.P62_REQ_UNPACK_FLAG, "1"); } Result = RBA_API.SetParam(PARAMETER_ID.P62_REQ_FAST_DOWNLOAD, "1"); Result = RBA_API.SetParam(PARAMETER_ID.P62_REQ_OS_FILE_NAME, form_file_path); Result = RBA_API.SetParam(PARAMETER_ID.P62_REQ_FILE_NAME, filename); Result = RBA_API.SetParam(PARAMETER_ID.P60_REQ_GROUP_NUM, "13"); Result = RBA_API.SetParam(PARAMETER_ID.P60_REQ_INDEX_NUM, "11"); Result = RBA_API.SetParam(PARAMETER_ID.P60_REQ_DATA_CONFIG_PARAM, "1"); Result = RBA_API.ProcessMessage(MESSAGE_ID.M60_CONFIGURATION_WRITE); Result = RBA_API.SetParam(PARAMETER_ID.P62_REQ_LAST_MESSAGE_TIMEOUT_SEC, "360"); ShowMessage("Device Form Loading ..."); Result = RBA_API.ProcessMessage(MESSAGE_ID.FILE_WRITE); Debug.WriteLine("DEVICE UPDATER: SetParam() FILE_WRITE RESULT-----------={0}", Result); } catch (Exception e) { Debug.WriteLine("DeviceConfig: EXCEPTION={0}", (object)e.Message); } return(Result); }
public ERROR_ID LoadForm(string formName, string message) { ERROR_ID Result = RBA_API.ProcessMessage(MESSAGE_ID.M01_ONLINE);; Debug.WriteLine("device online : {0} --------------------------------------------------", (object)result); Result = RBA_API.SetParam(PARAMETER_ID.P24_REQ_FORM_NUMBER, formName); Result = RBA_API.SetParam(PARAMETER_ID.P24_REQ_TYPE_OF_ELEMENT, StringEnum.GetStringValue(DeviceFormTypeOf.Text)); Result = RBA_API.SetParam(PARAMETER_ID.P24_REQ_TEXT_ELEMENTID, StringEnum.GetStringValue(DeviceFormElementID.PromptLine1)); Result = RBA_API.SetParam(PARAMETER_ID.P24_REQ_PROMPT_IDX, message); Result = RBA_API.ProcessMessage(MESSAGE_ID.M24_FORM_ENTRY); //Make sure the form shows on the device long enough for the user to see it //System.Threading.Thread.Sleep(4000); return(Result); }
public async Task <ERROR_ID> 요청_처리중인가([System.Runtime.CompilerServices.CallerFilePath] string fileName = "", [System.Runtime.CompilerServices.CallerMemberName] string methodName = "", [System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = 0) { double prevAllTimeSec = 0; var curAllTimeSec = Util.TimeTickToSec(DateTime.Now.Ticks); try { var result = await DB.Redis.GetString <double>(key); if (result.Item1) { prevAllTimeSec = result.Item2; if (prevAllTimeSec > 0) { return(요청을_할수있다); } } var changeData = await DB.Redis.Increment(key, curAllTimeSec); if (changeData != curAllTimeSec) { return(요청을_할수있다); } 요청을_할수있다 = ERROR_ID.NONE; return(요청을_할수있다); } catch (Exception ex) { Logger.Exception(ex.Message); return(ERROR_ID.PREV_REQUEST_FAIL_REDIS); } }
public ERROR_ID HardDeviceReset() { ERROR_ID result = RBA_API.ProcessMessage(MESSAGE_ID.M97_REBOOT); return(result); }
public ERROR_ID Offline() { ERROR_ID result = RBA_API.ProcessMessage(MESSAGE_ID.M00_OFFLINE); return(result); }
private void SetRebootTime(string action) { bool mode = true; string timeStamp = ""; // action can be either: a) True/False, b) HHMM if (action.IndexOf("True", StringComparison.InvariantCultureIgnoreCase) != -1 || action.IndexOf("False", StringComparison.InvariantCultureIgnoreCase) != -1) { mode = bool.Parse(action); Console.WriteLine("\r\nENABLE 24 HOUR REBOOT TEST ----------------------"); // Check is enabled bool enabled = Convert.ToBoolean(Convert.ChangeType(Get24RebootState(), typeof(uint))); if (enabled != mode) { Set24RebootState(mode ? "1" : "0"); enabled = Convert.ToBoolean(Convert.ChangeType(Get24RebootState(), typeof(uint))); Console.WriteLine($"24 HOUR REBOOT OPTION ENABLED : {enabled}"); if (!mode) { ERROR_ID result = WriteConfiguration("0007", "0046", "0"); Debug.WriteLine($"WriteConfiguration result : {result}"); } Offline(); HardDeviceReset(); } else { Console.WriteLine($"24 HOUR REBOOT OPTION ENABLED : {enabled}"); } return; } else { timeStamp = action; } string deviceRebootTime = Get24RebootTime(); string configRebootTime = timeStamp; //string configRebootTime = DateTime.Now.AddMinutes(5).ToString("HHmm"); //if the time needs to be set - then the device must reboot so that it stored the updated configuration if (deviceRebootTime != configRebootTime) { Console.WriteLine("\r\nENABLE 24 HOUR REBOOT TEST ----------------------"); // Check is enabled bool enabled = Convert.ToBoolean(Convert.ChangeType(Get24RebootState(), typeof(uint))); if (enabled != mode) { Set24RebootState(mode ? "1" : "0"); } enabled = Convert.ToBoolean(Convert.ChangeType(Get24RebootState(), typeof(uint))); Console.WriteLine($"24 HOUR REBOOT OPTION ENABLED : {enabled}"); ERROR_ID result = WriteConfiguration("0007", "0046", configRebootTime); Debug.WriteLine($"WriteConfiguration result : {result}"); // SAVE UPDATED REBOOT TIME deviceRebootTime = Get24RebootTime(); result = Offline(); Console.WriteLine($"Offline result : {result}"); result = HardDeviceReset(); Console.WriteLine($"HardDeviceReset result : {result}"); //notify DAL that the device is disconnected //NotificationRaise(new NotificationEventArgs { NotificationType = NotificationType.DeviceEvent, DeviceEvent = DeviceEvent.DeviceDisconnected }); Console.WriteLine($"DEVICE DAILY REBOOT TIME : {deviceRebootTime}\r\n"); } }
public ERROR_ID Set24RebootState(string mode) { ERROR_ID result = WriteConfiguration("0007", "0045", mode); return(result); }
public void Reset() { ERROR_ID Result = RBA_API.ProcessMessage(MESSAGE_ID.M10_HARD_RESET); }