public void ParseScriptAndRun(String base_path, ISerial serial_device, String script_stream, int stream_size) { // Script file is empty if (string.IsNullOrEmpty(script_stream.Trim())) { Errors.LogErrorNowAndContinue(new ScriptEmptyException()); this.OnError(); return; } Script script = new Script(); XmlSerializer s = new XmlSerializer(typeof(Script)); try { using (StringReader reader = new StringReader(script_stream.Substring(0, stream_size))) { script = (Script)s.Deserialize(reader); } buildScriptActions(base_path, serial_device, script); } catch (Exception e) { // Script file has invalid format or structure Errors.LogErrorNowAndContinue(new ScriptWrongStructureException()); this.OnError(); return; } this.Run(); }
private void Comm_OnTurnOnOffMtu(object sender, MTUComm.TurnOffMtuArgs args) { try { ActionResult resultBasic = getBasciInfoResult(); this.lastLogCreated = logger.TurnOnOff(this, args.Mtu, resultBasic); ActionFinishArgs finalArgs = new ActionFinishArgs(resultBasic); this.Finish(finalArgs); } catch (Exception e) { Errors.LogErrorNowAndContinue(new PuckCantCommWithMtuException()); this.OnError(); } }
public void ParseScriptAndRun(ISerial serial_device, String script_stream, int stream_size) { XmlSerializer s = null; try { // Script file is empty if (string.IsNullOrEmpty(script_stream.Trim())) { throw new ScriptEmptyException(); } Script script = new Script(); s = new XmlSerializer(typeof(Script)); // Register unknown elements ( not present in Script class ) as additional parameters s.UnknownElement += this.UnknownElementEvent; using (StringReader reader = new StringReader(script_stream.Substring(0, stream_size))) { script = ( Script )s.Deserialize(reader); } BuildScriptActions(serial_device, script); } catch (Exception e) { if (!Errors.IsOwnException(e)) { Errors.LogErrorNowAndContinue(new ScriptWrongStructureException()); // Script file has invalid format or structure } else { Errors.LogErrorNowAndContinue(e); // ScriptLogfileInvalidException, ScriptActionTypeInvalidException } this.OnError(); return; } finally { s.UnknownElement -= this.UnknownElementEvent; } this.Run(); }
private async Task Comm_OnAddMtu(object sender, MTUComm.AddMtuArgs args) { try { ActionResult result = await CreateActionResultUsingInterface(args.MemoryMap, args.MtuType, args.Form); ActionFinishArgs finalArgs = new ActionFinishArgs(result); args.AddMtuLog.LogReadMtu(result); this.lastLogCreated = args.AddMtuLog.Save(); this.Finish(finalArgs); } catch (Exception e) { Errors.LogErrorNowAndContinue(new PuckCantCommWithMtuException()); this.OnError(); } }
private async Task Comm_OnReadMtu(object sender, MTUComm.ReadMtuArgs args) { try { ActionResult resultAllInterfaces = await CreateActionResultUsingInterface(args.MemoryMap, args.Mtu); this.lastLogCreated = logger.ReadMTU(this, resultAllInterfaces, args.Mtu); ActionFinishArgs finalArgs = new ActionFinishArgs(resultAllInterfaces); finalArgs.Mtu = args.Mtu; this.Finish(finalArgs); } catch (Exception e) { Errors.LogErrorNowAndContinue(new PuckCantCommWithMtuException()); this.OnError(); } }