Syscont (779991), страница 8
Текст из файла (страница 8)
[1597] if((Fp1=fopen(Fname_entry,"r"))==NULL)
[1598] {
[1599] ALERT_SIGNAL;
[1600] perror("File_name_entry"); STOP;
[1601] exit(EXIT_FAILURE);
[1602] }
[1603] return 0;
[1604] }
[1605] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1606] int Openfile_exit()
[1607] {
[1608] BELL;
[1609] /*---- Var. File_name_exit */
[1610] /*
[1611] cputs(" File_name_exit --> ");
[1612] scanf("%s",&Fname_exit);
[1613] */
[1614] /*---- Const File_name-exit */
[1615] strcpy(Fname_exit,"Control.c");
[1616] /*----*/
[1617] if((Fp2=fopen(Fname_exit,"w"))==NULL)
[1618] {
[1619] ALERT_SIGNAL;
[1620] perror("File_name_exit"); STOP;
[1621] exit(EXIT_FAILURE);
[1622] }
[1623] /*----*/
[1624] return 0;
[1625] }
[1626] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1627] int Hand_order_var1()
[1628] {
[1629] char c[80];
[1630] /*============= Input*/
[1631] /*---- Input address A0, A1, A2 */
[1632] while(1)
[1633] {
[1634] BELL;
[1635] cputs("\r Address A0 (0 or 1) --> ");
[1636] scanf("%s",&c);
[1637] if(c[0]=='1' && c[1]=='\0') {A0=1; break;}
[1638] if(c[0]=='0' && c[1]=='\0') {A0=0; break;}
[1639] }
[1640] for(;;)
[1641] {
[1642] BELL;
[1643] cputs("\r Address A1 (0 or 1) --> ");
[1644] scanf("%s",&c);
[1645] if(c[0]=='1' && c[1]=='\0') {A1=1; break;}
[1646] if(c[0]=='0' && c[1]=='\0') {A1=0; break;}
[1647] }
[1648] do
[1649] {
[1650] BELL;
[1651] cputs("\r Address A2 (0 or 1) --> ");
[1652] scanf("%s",&c);
[1653] if(c[0]=='1' && c[1]=='\0') A2=1;
[1654] if(c[0]=='0' && c[1]=='\0') A2=0;
[1655] }while(c[0]!='0' && c[0]!='1' || c[1]!='\0');
[1656] /*---- Input commands */
[1657] while(1)
[1658] {
[1659] BELL;
[1660] cputs("\r Command C0 (0 or 1) --> ");
[1661] scanf("%s",&c);
[1662] if(c[0]=='1' && c[1]=='\0') {C0=1; break;}
[1663] if(c[0]=='0' && c[1]=='\0') {C0=0; break;}
[1664] }
[1665] for(;;)
[1666] {
[1667] BELL;
[1668] cputs("\r Command C1 (0 or 1) --> ");
[1669] scanf("%s",&c);
[1670] if(c[0]=='1' && c[1]=='\0') {C1=1; break;}
[1671] if(c[0]=='0' && c[1]=='\0') {C1=0; break;}
[1672] }
[1673] do
[1674] {
[1675] BELL;
[1676] cputs("\r Command C2 (0 or 1) --> ");
[1677] scanf("%s",&c);
[1678] if(c[0]=='1' && c[1]=='\0') C2=1;
[1679] if(c[0]=='0' && c[1]=='\0') C2=0;
[1680] }while(c[0]!='0' && c[0]!='1' || c[1]!='\0');
[1681] /*---- Interval ordered */
[1682] {
[1683] BELL;
[1684] cputs(" Interval_ordered (sec.) --> ");
[1685] scanf("%ld",&Interval_ordered);
[1686] }
[1687] /*----*/
[1688] Hint_ord=Interval_ordered/3600;
[1689] Mint_ord=Interval_ordered%3600/60;
[1690] Sint_ord=Interval_ordered%3600%60;
[1691] /*---- Messages exec */
[1692] strcpy(Messages_exec," ADD: ");
[1693] itoa((A2*4+A1*2+A0*1),c,10);
[1694] strcat(Messages_exec,c);
[1695] /*-*/
[1696] strcat(Messages_exec,", COM: ");
[1697] itoa((C2*4+C1*2+C0*1),c,10);
[1698] strcat(Messages_exec,c);
[1699] /*-*/
[1700] strcat(Messages_exec,", Interval (s): ");
[1701] itoa(Interval_ordered,c,10);
[1702] strcat(Messages_exec,c);
[1703] /*----*/
[1704] return 0;
[1705] }
[1706] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1707] int Hand_order_var2()
[1708] {
[1709] char c[80];
[1710] /*============= Input*/
[1711] /*---- Input address A0, A1, A2 */
[1712] while(1)
[1713] {
[1714] BELL;
[1715] cputs("\r Address A0 (0 or 1) --> ");
[1716] scanf("%s",&c);
[1717] if(c[0]=='1' && c[1]=='\0') {A0=1; break;}
[1718] if(c[0]=='0' && c[1]=='\0') {A0=0; break;}
[1719] }
[1720] for(;;)
[1721] {
[1722] BELL;
[1723] cputs("\r Address A1 (0 or 1) --> ");
[1724] scanf("%s",&c);
[1725] if(c[0]=='1' && c[1]=='\0') {A1=1; break;}
[1726] if(c[0]=='0' && c[1]=='\0') {A1=0; break;}
[1727] }
[1728] do
[1729] {
[1730] BELL;
[1731] cputs("\r Address A2 (0 or 1) --> ");
[1732] scanf("%s",&c);
[1733] if(c[0]=='1' && c[1]=='\0') A2=1;
[1734] if(c[0]=='0' && c[1]=='\0') A2=0;
[1735] }while(c[0]!='0' && c[0]!='1' || c[1]!='\0');
[1736] /*---- Input commands */
[1737] while(1)
[1738] {
[1739] BELL;
[1740] cputs("\r Command C0 (0 or 1) --> ");
[1741] scanf("%s",&c);
[1742] if(c[0]=='1' && c[1]=='\0') {C0=1; break;}
[1743] if(c[0]=='0' && c[1]=='\0') {C0=0; break;}
[1744] }
[1745] for(;;)
[1746] {
[1747] BELL;
[1748] cputs("\r Command C1 (0 or 1) --> ");
[1749] scanf("%s",&c);
[1750] if(c[0]=='1' && c[1]=='\0') {C1=1; break;}
[1751] if(c[0]=='0' && c[1]=='\0') {C1=0; break;}
[1752] }
[1753] do
[1754] {
[1755] BELL;
[1756] cputs("\r Command C2 (0 or 1) --> ");
[1757] scanf("%s",&c);
[1758] if(c[0]=='1' && c[1]=='\0') C2=1;
[1759] if(c[0]=='0' && c[1]=='\0') C2=0;
[1760] }while(c[0]!='0' && c[0]!='1' || c[1]!='\0');
[1761]
[1762] /*---- Order of the times */
[1763] for(;;)
[1764] {
[1765] BELL;
[1766] cputs("\n\r Time Hour (0-24) --> ");
[1767] cscanf("%2s",&c);
[1768] if((isdigit(c[0]))&&(isdigit(c[1]))&&(c[2]=='\0')||
[1769] (isdigit(c[0]))&&(c[1]=='\0'))
[1770] Ho=atoi(c);
[1771] else continue;
[1772] if(Ho<=24) break;
[1773] else continue;
[1774] }
[1775] for(;;)
[1776] {
[1777] BELL;
[1778] cputs("\n\r Time Min. (0-60) --> ");
[1779] cscanf("%2s",&c);
[1780] if((isdigit(c[0]))&&(isdigit(c[1]))&&(c[2]=='\0')||
[1781] (isdigit(c[0]))&&(c[1]=='\0'))
[1782] Mo=atoi(c);
[1783] else continue;
[1784] if(Mo<=60) break;
[1785] else continue;
[1786] }
[1787] for(;;)
[1788] {
[1789] BELL;
[1790] cputs("\n\r Time Sec. (0-60) --> ");
[1791] cscanf("%2s",&c);
[1792] if((isdigit(c[0]))&&(isdigit(c[1]))&&(c[2]=='\0')||
[1793] (isdigit(c[0]))&&(c[1]=='\0'))
[1794] So=atoi(c);
[1795] else continue;
[1796] if(So<=60) break;
[1797] else continue;
[1798] }
[1799] /*----*/
[1800] Time_ordered=(long int)(Ho*3600+Mo*60+So);
[1801] /*---- Messages exec */
[1802] strcpy(Messages_exec," ADD: ");
[1803] itoa((A2*4+A1*2+A0*1),c,10);
[1804] strcat(Messages_exec,c);
[1805] /*-*/
[1806] strcat(Messages_exec,", COM: ");
[1807] itoa((C2*4+C1*2+C0*1),c,10);
[1808] strcat(Messages_exec,c);
[1809] /*-*/
[1810] strcat(Messages_exec,", Hour: ");
[1811] itoa(Ho,c,10);
[1812] strcat(Messages_exec,c);
[1813] /*-*/
[1814] strcat(Messages_exec,", Min: ");
[1815] itoa(Mo,c,10);
[1816] strcat(Messages_exec,c);
[1817] /*-*/
[1818] strcat(Messages_exec,", Sec: ");
[1819] itoa(So,c,10);
[1820] strcat(Messages_exec,c);
[1821] /*-*/
[1822] return 0;
[1823] }
[1824] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1825] int Hand_order_var3()
[1826] {
[1827] BELL;
[1828] cputs(" Interval_ordered (sec.) --> ");
[1829] scanf("%ld",&Interval_ordered);
[1830] /*----*/
[1831] Hint_ord=Interval_ordered/3600;
[1832] Mint_ord=Interval_ordered%3600/60;
[1833] Sint_ord=Interval_ordered%3600%60;
[1834] /*----*/
[1835] return 0;
[1836] }
[1837] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1838] int File_order_var3()
[1839] {
[1840] if(feof(Fp1)) End_program();
[1841] fgets(Messages_exec,79,Fp1);
[1842] fscanf
[1843] (Fp1,"%1d%1d%1d---%1d%1d%1d\n",
[1844] &A2,&A1,&A0,&C2,&C1,&C0);
[1845] return 0;
[1846] }
[1847] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1848] int File_order_var4()
[1849] {
[1850] if(feof(Fp1)) End_program();
[1851] fgets(Messages_exec,79,Fp1);
[1852] fscanf
[1853] (Fp1,"%1d%1d%1d---%1d%1d%1d---%10ld\n",
[1854] &A2,&A1,&A0,&C2,&C1,&C0,&Interval_ordered);
[1855] /*----*/
[1856] Hint_ord=Interval_ordered/3600;
[1857] Mint_ord=Interval_ordered%3600/60;
[1858] Sint_ord=Interval_ordered%3600%60;
[1859] /*----*/
[1860] return 0;
[1861] }
[1862] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1863] int File_order_var5()
[1864] {
[1865] if(feof(Fp1)) End_program();
[1866] fgets(Messages_exec,79,Fp1);
[1867] fscanf
[1868] (Fp1,"%1d%1d%1d---%1d%1d%1d---%2d%2d%2d\n",
[1869] &A2,&A1,&A0,&C2,&C1,&C0,&Ho,&Mo,&So);
[1870] /*----*/
[1871] Time_ordered=(long int)(Ho*3600+Mo*60+So);
[1872] /*----*/
[1873] return 0;
[1874] }
[1875] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1876] int Get_time_pc_counted()
[1877] {
[1878] gettime(&Time_now);
[1879] /* */
[1880] H=(int)Time_now.ti_hour;
[1881] M=(int)Time_now.ti_min;
[1882] S=(int)Time_now.ti_sec;
[1883] Time_pc_counted=(int long)(H*3600+M*60+S);
[1884] /* */
[1885] return 0;
[1886] }
[1887] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1888] int Get_date_pc_counted()
[1889] {
[1890] /*---- Variables */
[1891] struct tm *ptr;
[1892] time_t lt;
[1893] /*----*/
[1894] lt=time(NULL);
[1895] ptr=localtime(<);
[1896] strcpy(Str_date_pc_counted,asctime(ptr));
[1897] /* */
[1898] return 0;
[1899] }
[1900] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1901] int Get_number_commands()
[1902] {
[1903] while(1)
[1904] {
[1905] if(feof(Fp1)) break;
[1906] fgets(Messages_exec,79,Fp1);
[1907] /*---- Regime 3 */
[1908] if(Regime_work[0]=='3')
[1909] fscanf
[1910] (Fp1,"%1d%1d%1d---%1d%1d%1d\n",
[1911] &A2,&A1,&A0,&C2,&C1,&C0);
[1912] /*---- Regime 4 */
[1913] if(Regime_work[0]=='4')
[1914] fscanf
[1915] (Fp1,"%1d%1d%1d---%1d%1d%1d---%10ld\n",
[1916] &A2,&A1,&A0,&C2,&C1,&C0,&Interval_ordered);
[1917] /*---- Regime 5 */
[1918] if(Regime_work[0]=='5')
[1919] fscanf
[1920] (Fp1,"%1d%1d%1d---%1d%1d%1d---%2d%2d%2d\n",
[1921] &A2,&A1,&A0,&C2,&C1,&C0,&Ho,&Mo,&So);
[1922] /*---- Regime 6 */
[1923] if(Regime_work[0]=='6')
[1924] fscanf
[1925] (Fp1,"%1d%1d%1d---%1d%1d%1d\n",
[1926] &A2,&A1,&A0,&C2,&C1,&C0);
[1927] /*----*/
[1928] Number_commands++;
[1929] }
[1930] rewind(Fp1);
[1931] /*----*/
[1932] return 0;
[1933] }
[1934] /*IIIIIIIIIIIIIIIIIIIIIIIIIIIIII*/
[1935] String_int_ordered()
[1936] {
[1937] /*---- Variables */
[1938] char str_sint_ord[4];
[1939] char str_mint_ord[4];
[1940] char str_hint_ord[4];
[1941] /*----*/
[1942] itoa(Hint_ord,str_hint_ord,10);
[1943] itoa(Mint_ord,str_mint_ord,10);
[1944] itoa(Sint_ord,str_sint_ord,10);
[1945] /*----*/
[1946] strcpy(Str_int_ordered,str_hint_ord);