Esempio n. 1
0
        public static bool ByName(object pa, object pb)
        {
            Itinerary ia = (Itinerary)pa;
            Itinerary ib = (Itinerary)pb;

            return(Globals.wxStricmp(ia.name, ib.name));
        }
Esempio n. 2
0
        public static void toggle_itinerary(Itinerary it)
        {
            Track  t1;
            int    i;
            String nextitin;

            do
            {
                for (i = 0; i < it.nsects; ++i)
                {
                    t1 = findSwitch(it.sw[i].x, it.sw[i].y);
                    if (it.sw[i].switched != t1.switched)
                    {
                        t1.switched = !t1.switched;
                        change_coord(t1.x, t1.y);
                        if ((t1 = findSwitch(t1.wlinkx, t1.wlinky)) != null)
                        {
                            t1.switched = !t1.switched;
                            change_coord(t1.x, t1.y);
                        }
                    }
                }
                if (((nextitin = it.nextitin) != null) || (nextitin.Length == 0))
                {
                    return;
                }
                for (it = itineraries; it != null; it = it.next)
                {
                    if (Globals.wxStrcmp(it.name, nextitin) == 0)
                    {
                        break;
                    }
                }
            } while(it != null);                /* always true */
        }
Esempio n. 3
0
        public static void add_itinerary(Itinerary it, int x, int y, bool sw)
        {
            int i;

            for (i = 0; i < it.nsects; ++i)
            {
                if (it.sw[i].x == x && it.sw[i].y == y)
                {
                    it.sw[i].switched = sw;
                    return;
                }
            }
            if (it.nsects >= it.maxsects)
            {
                it.maxsects += 10;
                if (it.sw == null)
                {
                    it.sw = new switin[it.maxsects];
                }
                else
                {
                    it.sw = Globals.realloc(it.sw, it.maxsects);
                }
            }
            it.sw[it.nsects].x        = x;
            it.sw[it.nsects].y        = y;
            it.sw[it.nsects].switched = sw;
            ++it.nsects;
        }
Esempio n. 4
0
        public void OnDelete(object sender, Event evt)
        {
            Itinerary it = (Itinerary)GetSelectedData();

            if (it == null)             // impossible
            {
                return;
            }
            Globals.delete_itinerary(it);
            Globals.FillItineraryTable();
        }
Esempio n. 5
0
        public static int green_itinerary(Itinerary it)
        {
            Signal    t1;
            Itinerary ip;
            String    nextitin;
            int       i;

            Signal[] blocks = new Signal[100];
            int      nxtblk;

            nxtblk = 0;
            for (ip = it; ip != null;)
            {
                if ((t1 = findSignalNamed(ip.signame)) != null)
                {
                    return(0);
                }
                if (t1.status == trkstat.ST_GREEN)
                {
                    return(0);
                }
                blocks[nxtblk++] = t1;
                if (((nextitin = ip.nextitin) == null) || (nextitin.Length == 0))
                {
                    break;              /* done */
                }
                for (ip = itineraries; ip != null; ip = ip.next)
                {
                    if (Globals.wxStrcmp(ip.name, nextitin) == 0)
                    {
                        break;
                    }
                }
            }

            /* all signals are red, try to turn them green */

            for (i = 0; i < nxtblk; ++i)
            {
                if (toggle_signal(blocks[i]))
                {
                    break;              /* line block is busy */
                }
            }
            if (i >= nxtblk)            /* success! */
            {
                return(1);
            }
            while (--i >= 0)            /* undo signal toggling */
            {
                toggle_signal(blocks[i]);
            }
            return(0);
        }
Esempio n. 6
0
        public static int check_itinerary(Itinerary it)
        {
            String nextitin;
            Track  t1;
            int    i;

            clear_visited();
agn:
            if (it == null || it.visited)
            {
                return(0);
            }
            for (i = 0; i < it.nsects; ++i)
            {
                t1 = findSwitch(it.sw[i].x, it.sw[i].y);
                if (t1 == null || t1.fgcolor == color_green)
                {
                    return(0);
                }
                it.sw[i].oldsw = t1.switched;
                if (it.sw[i].switched != t1.switched)
                {
                    if ((t1 = findSwitch(t1.wlinkx, t1.wlinky)) != null)
                    {
                        if (t1.fgcolor == color_green)
                        {
                            return(0);
                        }
                    }
                }
            }
            if ((nextitin = it.nextitin) == null || nextitin.Length == 0)
            {
                return(1);
            }
            it.visited = true;
            for (it = itineraries; it != null; it = it.next)
            {
                if (Globals.wxStrcmp(it.name, nextitin) == 0)
                {
                    break;
                }
            }
            goto agn;
        }
Esempio n. 7
0
 public static void free_itinerary(Itinerary it)
 {
     if (String.IsNullOrEmpty(it.signame) == false)
     {
         Globals.free(it.signame);
     }
     if (String.IsNullOrEmpty(it.endsig) == false)
     {
         Globals.free(it.endsig);
     }
     if (String.IsNullOrEmpty(it.name) == false)
     {
         Globals.free(it.name);
     }
     if (it.sw != null)
     {
         Globals.free(it.sw);
     }
     Globals.free(it);
 }
Esempio n. 8
0
        public static void delete_itinerary(String name)
        {
            Itinerary it, oit;

            oit = null;
            for (it = itineraries; it != null && Globals.wxStrcmp(it.name, name) != 0; it = it.next)
            {
                oit = it;
            }
            if (it == null)
            {
                return;
            }
            if (oit == null)
            {
                itineraries = it.next;
            }
            else
            {
                oit.next = it.next;
            }
            free_itinerary(it);
        }
Esempio n. 9
0
        public static void delete_itinerary(Itinerary ip)
        {
            Itinerary it, oit;

            oit = null;
            for (it = itineraries; it != null && ip != it; it = it.next)
            {
                oit = it;
            }
            if (it == null)
            {
                return;
            }
            if (oit == null)
            {
                itineraries = it.next;
            }
            else
            {
                oit.next = it.next;
            }
            free_itinerary(it);
        }
Esempio n. 10
0
        public static void try_itinerary(int sx, int sy, int ex, int ey)
        {
            Itinerary it = null;
            Signal    t1, t2;

            t1 = findSignal(sx, sy);
            t2 = findSignal(ex, ey);
            if (t1 == null || t2 == null)
            {
                return;
            }
            if (String.IsNullOrEmpty(t1.station) == false && String.IsNullOrEmpty(t2.station) == false)
            {
                for (it = itineraries; it != null; it = it.next)
                {
                    if ((Globals.wxStrcmp(it.signame, t1.station) == 0) &&
                        (Globals.wxStrcmp(it.endsig, t2.station) == 0))
                    {
                        break;
                    }
                }
            }
            itinerary_selected(it);
        }
Esempio n. 11
0
 public static void itinerary_selected(Itinerary it)
 {
     it.Select();
 }