public void OnEvent(BaseEvent evt) { using (var l = new Logger("Listener")) { if (evt is FlexEvent) { var fxe = evt as FlexEvent; if (fxe.Operation.StartsWith("SQL.Corrections")) { var fex = new FlexHelper(fxe); if (fex.GetStr(MainWindow.ArgCommandName) == "GetScheme") { if (fex.GetStr(MainWindow.ArgErrorCodeName) == "S_OK") { var itemLst = (List<int>) fex.GetComplexArg("ITEM", typeof (List<int>)); var cminLst = (List<double>) fex.GetComplexArg("CMIN", typeof (List<double>)); var cmaxLst = (List<double>) fex.GetComplexArg("CMAX", typeof (List<double>)); var oxygenLst = (List<double>) fex.GetComplexArg("OXYGEN", typeof (List<double>)); var heatinLst = (List<double>) fex.GetComplexArg("HEATING", typeof (List<double>)); Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() { Pointer.PMainWindow.TableData = new List<TableRow>(); Pointer.PMainWindow.StandartTableData = new List<TableRow>(); for (int i = 0; i < fex.GetInt(MainWindow.ArgCountName); i++) { var tr = new TableRow(); tr.Item = itemLst[i]; tr.CMin = cminLst[i]; tr.CMax = cmaxLst[i]; tr.Oxygen = oxygenLst[i]; tr.Heating = heatinLst[i]; Pointer.PMainWindow.StandartTableData.Add(new TableRow(tr)); tr.Item = i; Pointer.PMainWindow.TableData.Add(new TableRow(tr)); } Pointer.PMainWindow.dgScheme.ItemsSource =Pointer.PMainWindow.TableData; Pointer.PMainWindow.dgScheme.Items.Refresh(); Pointer.PMainWindow.btnSave.IsEnabled = true; Pointer.PMainWindow.LogWrite("Scheme loaded"); })); } else { Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() { Pointer.PMainWindow.LogWrite(fex.GetStr(MainWindow.ArgErrorStringName)); })); } } if (fex.GetStr(MainWindow.ArgCommandName) == "InsertSchemeRow") { if (fex.GetStr(MainWindow.ArgErrorCodeName) == "S_OK") { Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() { Pointer.PMainWindow.TableChangeCounter--; if (Pointer.PMainWindow.TableChangeCounter == 0) { Pointer.PMainWindow.ReqScheme(Pointer.PMainWindow.CurrentSchema); Pointer.PMainWindow.LogWrite("Save complete"); } })); } else { Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() { Pointer.PMainWindow.LogWrite("Scheme save error"); })); } } if (fex.GetStr(MainWindow.ArgCommandName) == "UpdateSchemeRow") { if (fex.GetStr(MainWindow.ArgErrorCodeName) == "S_OK") { Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() { Pointer.PMainWindow.TableChangeCounter--; if (Pointer.PMainWindow.TableChangeCounter == 0) { Pointer.PMainWindow.ReqScheme(Pointer.PMainWindow.CurrentSchema); Pointer.PMainWindow.LogWrite("Save complete"); } })); } else { Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() { Pointer.PMainWindow.LogWrite("Scheme Update error"); })); } } if (fex.GetStr(MainWindow.ArgCommandName) == "DeleteSchemeRow") { if (fex.GetStr(MainWindow.ArgErrorCodeName) == "S_OK") { Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() { Pointer.PMainWindow.TableChangeCounter--; if (Pointer.PMainWindow.TableChangeCounter == 0) { Pointer.PMainWindow.ReqScheme(Pointer.PMainWindow.CurrentSchema); Pointer.PMainWindow.LogWrite("Save complete"); } })); } else { Pointer.PMainWindow.Dispatcher.Invoke(new Action(delegate() { Pointer.PMainWindow.LogWrite("Scheme Delete error"); })); } } } } } }
public void OnEvent(BaseEvent newEvent) { // System.Threading.Thread.Sleep(3000); // InstantLogger.log(newEvent.GetType().GetCustomAttributesData()[5].ToString()); //if (!(newEvent is SteelMakingPatternEvent)) if ((newEvent is visAdditionTotalEvent)) InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.error); if (newEvent is visSpectrluksEvent) InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.error); if (newEvent is FlexEvent) { var flx = newEvent as FlexEvent; if (flx.Operation.StartsWith("TestComplex")) { var fxe = new FlexHelper(flx); var dimm = (int[]) fxe.GetComplexArg("dimm", typeof (int[])); Console.WriteLine("Receive:"); foreach (var i in dimm) Console.Write((i + ", ")); } } //var v = (PLCGroup)newEvent.GetType().GetCustomAttributes(false).Where(x => x.GetType().Name == "PLCGroup").FirstOrDefault(); //object first = null; /* InstantLogger.log(newEvent.GetType().FullName); var plcg = new PLCGroup(); foreach (object x in newEvent.GetType().GetCustomAttributes(false)) { if (x.GetType().Name == "PLCGroup") { plcg = (PLCGroup)x; InstantLogger.log(" " + plcg.Location + " -- " + plcg.Destination); } } var plcp = new PLCPoint(); foreach (var prop in newEvent.GetType().GetProperties()) { foreach (object x in prop.GetCustomAttributes(false)) { if (x.GetType().Name == "PLCPoint") { if (((PLCPoint)x).IsWritable) { plcp = (PLCPoint)x; //prop.GetValue(newEvent, null); //prop.GetValue(newEvent); InstantLogger.log(" " + prop.Name + " = " + prop.GetValue(newEvent, null).ToString()); InstantLogger.log(" IsWritable = " + plcp.IsWritable.ToString()); InstantLogger.log(" " + plcp.Location); // break; } } } } */ //if ( // (newEvent is cntBlowingSchemaEvent) || // (newEvent is comBlowingSchemaEvent) || // (newEvent is cntWatchDogPLC01Event) || // (newEvent is cntWatchDogPLC1Event) || // (newEvent is cntWatchDogPLC2Event) || // (newEvent is cntWatchDogPLC3Event) || // (newEvent is comO2FlowRateEvent) || // (newEvent is cntO2FlowRateEvent) // ) //{ // // SteelMakingPatternEvent steelMakingPatternEvent = newEvent as SteelMakingPatternEvent; // InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.death); //} //if( // (newEvent is comAdditionsEvent) || // (newEvent is comAdditionsSchemaEvent) // ) //{ // InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.terror); //} //if (newEvent is HeatSchemaStepEvent) //{ // InstantLogger.log("step = " + newEvent.ToString(), "Received", InstantLogger.TypeMessage.caution); //} //if ((newEvent is cntWeigher3JobReadyEvent) || // (newEvent is cntWeigher4JobReadyEvent)|| // (newEvent is cntWeigher5JobReadyEvent)|| // (newEvent is cntWeigher6JobReadyEvent)|| // (newEvent is cntWeigher7JobReadyEvent)) //{ // InstantLogger.log("step = " + newEvent.ToString(), "Received", InstantLogger.TypeMessage.normal); //} /*if (newEvent is SteelMakingPatternEvent) { SteelMakingPatternEvent steelMakingPatternEvent = newEvent as SteelMakingPatternEvent; InstantLogger.log(steelMakingPatternEvent.steps[0].Period.ToString(), "Received", InstantLogger.TypeMessage.important); }*/ // lock (Program.consoleLock) //{ /* Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" " + newEvent.ToString() + "\n"); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.ForegroundColor = ConsoleColor.Gray; logFile.Write(newEvent.ToString() + "\n");*/ // InstantLogger.log(newEvent.ToString(), "Received", InstantLogger.TypeMessage.unimportant); //logFile.Close(); //} //MessageBox.Show("ll", "ll"); }
public static CSVTableParser LoadMatrixTFromFlex(List<ColumnPath> description, FlexHelper fex) { var matrixT = new CSVTableParser(); matrixT.Description = description; var cminLst = (List<double>)fex.GetComplexArg("CMIN", typeof(List<double>)); var cmaxLst = (List<double>)fex.GetComplexArg("CMAX", typeof(List<double>)); var oxygenLst = (List<double>)fex.GetComplexArg("OXYGEN", typeof(List<double>)); var heatinLst = (List<double>)fex.GetComplexArg("HEATING", typeof(List<double>)); for (int i = 0; i < fex.GetInt(Implements.DBFlex.ArgCountName); i++) { var row = matrixT.ColumnCreator(); row.Cell["CMin"] = cminLst[i]; row.Cell["CMax"] = cmaxLst[i]; row.Cell["OxygenOnHeating"] = oxygenLst[i]; row.Cell["Heating"] = heatinLst[i]; matrixT.Rows.Add(row); } return matrixT; }