public static TypePix GetPixPrevNext(ChronopicRegisterPort.Types type, string direction) { int currentPos = 0; int nextPos = 0; foreach (TypePix tp in l) { if (tp.Type == type) { if (direction == "LEFT") { nextPos = currentPos - 1; if (nextPos < 0) { nextPos = 0; } } else { nextPos = currentPos + 1; if (nextPos > l.Count - 1) { nextPos = l.Count - 1; } } return(l[nextPos]); } currentPos++; } return(l[0]); //if there are problems, return UNKNOWN value }
//returns first found (should be only one if called NumConnectedOfType and returned value was 1 public ChronopicRegisterPort ConnectedOfType(ChronopicRegisterPort.Types type) { foreach (ChronopicRegisterPort crp in crpl.L) { if (crp.Type == type && crp.Port != "") { return(crp); } } return(null); }
public static Pixbuf GetPix(ChronopicRegisterPort.Types type) { foreach (TypePix tp in l) { if (tp.Type == type) { return(tp.Pix); } } return(l[0].Pix); //return first value if there are problems }
public static void Update(bool dbconOpened, ChronopicRegisterPort crp, ChronopicRegisterPort.Types newType) { openIfNeeded(dbconOpened); dbcmd.CommandText = "UPDATE " + table + " SET type = \"" + newType.ToString() + "\" WHERE serialNumber = \"" + crp.SerialNumber + "\""; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); closeIfNeeded(dbconOpened); }
public int NumConnectedOfType(ChronopicRegisterPort.Types type) { int count = 0; foreach (ChronopicRegisterPort crp in crpl.L) { if (crp.Type == type && crp.Port != "") { count++; } } return(count); }
public void UpdateType(ChronopicRegisterPort crp, ChronopicRegisterPort.Types newType) { //Update SQL SqliteChronopicRegister.Update(false, crp, newType); //Update list foreach (ChronopicRegisterPort c in L) { if (c.SerialNumber == crp.SerialNumber) { c.Type = newType; break; } } }
private void assignLastConnectedVariables(ChronopicRegisterPort crp) { if (cpDoing == 1) { lastConnectedRealPort = crp.Port; lastConnectedRealSerialNumber = crp.SerialNumber; lastConnectedRealType = ChronopicRegisterPort.Types.CONTACTS; } else //2 { lastConnectedRealPort2 = crp.Port; lastConnectedRealSerialNumber2 = crp.SerialNumber; lastConnectedRealType2 = ChronopicRegisterPort.Types.CONTACTS; } }
private void connectContactsRealDo() { ChronopicRegisterPort crp = crpConnectContactsRealThread; string message = ""; bool success = false; bool connected = false; if(cpDoing == 1) { sp = new SerialPort(crp.Port); chronopicInit = new ChronopicInit(); connected = chronopicInit.Do(1, out cp, out sp, platformState, crp.Port, out message, out success); } else //(cpDoing == 2) { sp2 = new SerialPort(crp.Port); chronopicInit = new ChronopicInit(); connected = chronopicInit.Do(2, out cp2, out sp2, platformState, crp.Port, out message, out success); } LogB.Information("Ended chronopicInit.Do()"); if(connected) { lastConnectedRealPort = crp.Port; lastConnectedRealSerialNumber = crp.SerialNumber; lastConnectedRealType = ChronopicRegisterPort.Types.CONTACTS; } SuccededConnectContactsRealThread = connected; }
private void updateSQL(string serialNumber, ChronopicRegisterPort.Types type) { //store on SQL SqliteChronopicRegister.Update(false, new ChronopicRegisterPort(serialNumber, type), type); }
private void buttons_sensitivity(Gtk.Button left, Gtk.Button right, ChronopicRegisterPort.Types type) { left.Sensitive = (type != TypePixList.l[0].Type); right.Sensitive = (type != TypePixList.l[TypePixList.l.Count - 1].Type); //LogB.Information("count + tplcount " + count + "," + TypePixList.l.Count); }
public TypePix(ChronopicRegisterPort.Types type, Pixbuf pix) { Type = type; Pix = pix; }