parent
8b48f3177a
commit
28881b136b
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@ -0,0 +1,123 @@
|
||||
INF=100000
|
||||
|
||||
# shelfMatrixLabel = ["SH1-L1", "SH1-L2", "SH1-L3", "SH1-L4", "SH1-L5", "SH2-L1", "SH2-L2", "SH2-L3", "SH2-L4", "SH2-L5", "SH3-L1", "SH3-L2", "SH3-L3", "SH3-L4", "SH3-L5"]
|
||||
# shelfMatrix = []
|
||||
|
||||
|
||||
# dmatrixLabel = ['B7', 'C1', 'C4', 'D0', 'E2', 'E4', 'E9', 'E8', 'F2', 'F4', 'G6', 'H1', 'I0', 'I6', 'I9', 'J0', 'J1', 'J6', 'K8', 'L2', 'L3', 'L7', 'L8', 'M7', 'M9', 'N1', 'N2', 'N3', 'N4', 'N6', 'O1', 'O2', 'O3', 'Q3', 'Q6', 'Q7', 'R3', 'S8', 'T4', 'U0', 'U5', 'U2', 'V1', 'V3', 'V7', 'X6', 'Y5', 'Z4']
|
||||
|
||||
# dmatrixLabel = ['A0', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2', 'E1', 'E2', 'F1', 'F2', 'G1', 'G2', 'H1', 'H2', 'I1', 'I2', 'J1', 'J2', 'K1', 'K2', 'L1', 'L2', 'M1', 'M2', 'N1', 'N2', 'P1', 'P2', 'Q1', 'Q2', 'R1', 'R2', 'S1', 'S2', 'T1', 'T2', 'U1', 'U2', 'V1', 'V2', 'W1', 'W2', 'X1', 'X2', 'Y1', 'Y2']
|
||||
|
||||
dmatrixLabel = ['A0', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2', 'E1', 'E2', 'F1', 'F2', 'G1', 'G2', 'H1', 'H2', 'I1', 'I2', 'J1', 'J2', 'K1', 'K2', 'L1', 'L2', 'M1', 'M2', 'N1', 'N2', 'P1', 'P2', 'Q1', 'Q2', 'R1', "SH1-L1", "SH1-L2", "SH1-L3", "SH1-L4", "SH1-L5", "SH2-L1", "SH2-L2", "SH2-L3", "SH2-L4", "SH2-L5", "SH3-L1", "SH3-L2", "SH3-L3", "SH3-L4", "SH3-L5"]
|
||||
|
||||
|
||||
dmatrix = [
|
||||
[ 0, 4727, 1205, 6363, 3657, 3130, 2414, 563, 463, 5654, 1713, 1604, 2368, 2201, 1290, 1004, 3833, 2258, 3419, 2267, 2957, 720, 1700, 5279, 2578, 6076, 3465, 2654, 3625, 3115, 1574, 3951, 1748, 2142, 6755, 2383, 3306, 1029, 3530, 825, 2188, 4820, 3489, 1947, 6835, 1542, 2379, 3744],
|
||||
[ 4727, 0, 3588, 2012, 1842, 6977, 6501, 5187, 5028, 2327, 4148, 4723, 3635, 3125, 4907, 3930, 7463, 6338, 7243, 5105, 4043, 4022, 3677, 2863, 3106, 1850, 7173, 6630, 1204, 6814, 6001, 3447, 5253, 2656, 3123, 6274, 7183, 5622, 3085, 4564, 2756, 1591, 7027, 6186, 3472, 5461, 4390, 2088],
|
||||
[ 1205, 3588, 0, 5163, 2458, 3678, 3071, 1742, 1444, 4462, 1184, 1520, 1498, 1103, 1501, 951, 4298, 2903, 3967, 2169, 2209, 652, 828, 4136, 1518, 4873, 3954, 3254, 2446, 3581, 2441, 2960, 1966, 950, 5564, 2916, 3878, 2035, 2482, 1027, 1395, 3617, 3891, 2686, 5661, 2023, 1867, 2560],
|
||||
[ 6363, 2012, 5163, 0, 2799, 8064, 7727, 6878, 6581, 1402, 5366, 5946, 4679, 4378, 6225, 5709, 8417, 7578, 8296, 6135, 4802, 5707, 4982, 2322, 4178, 320, 8186, 7800, 2778, 7859, 7408, 3763, 6461, 4223, 1427, 7451, 8263, 7131, 3669, 6011, 4638, 1681, 7987, 7502, 1877, 6758, 5360, 2844],
|
||||
[ 3657, 1842, 2458, 2799, 0, 5330, 4946, 4200, 3824, 2012, 2573, 3157, 1924, 1580, 3427, 3179, 5749, 4793, 5577, 3409, 2223, 3066, 2185, 1860, 1401, 2491, 5486, 5035, 894, 5141, 4611, 1669, 3677, 1590, 3113, 4682, 5533, 4352, 1252, 3227, 2426, 1169, 5313, 4706, 3241, 3962, 2651, 304],
|
||||
[ 3130, 6977, 3678, 8064, 5330, 0, 743, 3209, 2670, 6929, 2831, 2266, 3407, 3854, 2178, 4076, 727, 881, 293, 1930, 3310, 3672, 3315, 6199, 3932, 7745, 365, 482, 5774, 261, 1659, 4513, 1746, 4431, 7910, 769, 207, 2225, 4435, 2681, 5053, 6384, 550, 1224, 7805, 1670, 2704, 5230],
|
||||
[ 2414, 6501, 3071, 7727, 4946, 743, 0, 2468, 1952, 6673, 2380, 1795, 3051, 3405, 1604, 3382, 1469, 168, 1020, 1681, 3110, 2993, 2827, 6009, 3552, 7412, 1104, 267, 5300, 821, 916, 4348, 1270, 3890, 7698, 332, 900, 1484, 4185, 2049, 4415, 6051, 1219, 482, 7635, 1054, 2432, 4884],
|
||||
[ 563, 5187, 1742, 6878, 4200, 3209, 2468, 0, 718, 6203, 2241, 2051, 2920, 2762, 1687, 1304, 3932, 2331, 3487, 2669, 3487, 1175, 2260, 5840, 3141, 6596, 3563, 2728, 4120, 3240, 1559, 4507, 2082, 2658, 7304, 2512, 3364, 985, 4091, 1319, 2544, 5358, 3632, 1987, 7391, 1785, 2879, 4296],
|
||||
[ 463, 5028, 1444, 6581, 3824, 2670, 1952, 718, 0, 5789, 1602, 1343, 2330, 2291, 970, 1451, 3376, 1796, 2959, 1951, 2835, 1112, 1725, 5346, 2628, 6285, 3007, 2193, 3889, 2661, 1122, 3920, 1372, 2391, 6883, 1927, 2845, 611, 3543, 676, 2590, 4993, 3039, 1486, 6934, 1112, 2196, 3876],
|
||||
[ 5654, 2327, 4462, 1402, 2012, 6929, 6673, 6203, 5789, 0, 4392, 4947, 3648, 3501, 5274, 5183, 7216, 6535, 7140, 5022, 3621, 5077, 4090, 922, 3207, 1131, 7014, 6714, 2437, 6707, 6477, 2476, 5432, 3599, 1102, 6376, 7121, 6284, 2497, 5160, 4318, 937, 6795, 6507, 1268, 5773, 4249, 1914],
|
||||
[ 1713, 4148, 1184, 5366, 2573, 2831, 2380, 2241, 1602, 4392, 0, 586, 766, 1029, 883, 2040, 3353, 2224, 3100, 1049, 1246, 1625, 503, 3841, 1196, 5054, 3042, 2488, 2945, 2676, 2087, 2331, 1114, 1650, 5459, 2132, 3037, 1958, 1997, 931, 2513, 3701, 2923, 2137, 5459, 1394, 711, 2534],
|
||||
[ 1604, 4723, 1520, 5946, 3157, 2266, 1795, 2051, 1343, 4947, 586, 0, 1299, 1612, 406, 2208, 2824, 1639, 2542, 694, 1586, 1767, 1050, 4357, 1770, 5633, 2498, 1907, 3520, 2128, 1558, 2778, 531, 2171, 6003, 1552, 2472, 1538, 2506, 791, 2912, 4277, 2403, 1564, 5983, 827, 892, 3109],
|
||||
[ 2368, 3635, 1498, 4679, 1924, 3407, 3051, 2920, 2330, 3648, 766, 1299, 0, 646, 1642, 2446, 3840, 2905, 3655, 1488, 730, 2096, 697, 3076, 533, 4363, 3567, 3122, 2453, 3219, 2842, 1592, 1791, 1480, 4706, 2772, 3610, 2721, 1232, 1656, 2550, 3001, 3403, 2860, 4697, 2126, 756, 1836],
|
||||
[ 2201, 3125, 1103, 4378, 1580, 3854, 3405, 2762, 2291, 3501, 1029, 1612, 646, 0, 1853, 2026, 4349, 3247, 4119, 1997, 1341, 1753, 606, 3078, 419, 4070, 4052, 3517, 1923, 3690, 3032, 1866, 2142, 838, 4593, 3161, 4060, 2788, 1380, 1663, 1932, 2736, 3915, 3138, 4647, 2395, 1351, 1592],
|
||||
[ 1290, 4907, 1501, 6225, 3427, 2178, 1604, 1687, 970, 5274, 883, 406, 1642, 1853, 0, 2029, 2803, 1438, 2466, 986, 1987, 1593, 1253, 4716, 2072, 5915, 2454, 1764, 3710, 2082, 1204, 3164, 497, 2287, 6342, 1419, 2379, 1134, 2867, 554, 2885, 4569, 2405, 1289, 6338, 555, 1297, 3406],
|
||||
[ 1004, 3930, 951, 5709, 3179, 4076, 3382, 1304, 1451, 5183, 2040, 2208, 2446, 2026, 2029, 0, 4759, 3220, 4368, 2900, 3151, 442, 1765, 4960, 2444, 5443, 4396, 3610, 2932, 4034, 2572, 3891, 2525, 1590, 6278, 3313, 4261, 2033, 3398, 1476, 1241, 4287, 4390, 2928, 6419, 2428, 2749, 3337],
|
||||
[ 3833, 7463, 4298, 8417, 5749, 727, 1469, 3932, 3376, 7216, 3353, 2824, 3840, 4349, 2803, 4759, 0, 1601, 477, 2359, 3617, 4345, 3851, 6433, 4372, 8098, 370, 1206, 6267, 726, 2384, 4754, 2335, 4991, 8148, 1452, 609, 2949, 4752, 3331, 5687, 6746, 437, 1948, 8005, 2334, 3098, 5618],
|
||||
[ 2258, 6338, 2903, 7578, 4793, 881, 168, 2331, 1796, 6535, 2224, 1639, 2905, 3247, 1438, 3220, 1601, 0, 1165, 1563, 2988, 2829, 2666, 5882, 3401, 7263, 1233, 399, 5138, 923, 794, 4227, 1117, 3724, 7565, 286, 1049, 1348, 4051, 1881, 4248, 5903, 1322, 355, 7508, 887, 2302, 4736],
|
||||
[ 3419, 7243, 3967, 8296, 5577, 293, 1020, 3487, 2959, 7140, 3100, 2542, 3655, 4119, 2466, 4368, 477, 1165, 0, 2170, 3520, 3965, 3588, 6393, 4183, 7977, 202, 767, 6041, 438, 1932, 4706, 2027, 4711, 8107, 1061, 132, 2503, 4652, 2972, 5344, 6617, 486, 1501, 7989, 1962, 2939, 5469],
|
||||
[ 2267, 5105, 2169, 6135, 3409, 1930, 1681, 2669, 1951, 5022, 1049, 694, 1488, 1997, 986, 2900, 2359, 1563, 2170, 0, 1430, 2460, 1547, 4333, 2019, 5817, 2079, 1694, 3910, 1733, 1813, 2668, 654, 2694, 6029, 1366, 2130, 1991, 2525, 1474, 3542, 4455, 1923, 1641, 5957, 1071, 777, 3302],
|
||||
[ 2957, 4043, 2209, 4802, 2223, 3310, 3110, 3487, 2835, 3621, 1246, 1586, 730, 1341, 1987, 3151, 3617, 2988, 3520, 1430, 0, 2779, 1387, 2905, 1062, 4482, 3398, 3119, 2922, 3087, 3115, 1240, 1953, 2175, 4607, 2796, 3501, 3119, 1136, 2173, 3268, 3136, 3189, 3029, 4527, 2355, 711, 2042],
|
||||
[ 720, 4022, 652, 5707, 3066, 3672, 2993, 1175, 1112, 5077, 1625, 1767, 2096, 1753, 1593, 442, 4345, 2829, 3965, 2460, 2779, 0, 1401, 4781, 2166, 5427, 3984, 3212, 2946, 3620, 2224, 3603, 2089, 1496, 6178, 2906, 3861, 1719, 3132, 1040, 1479, 4211, 3969, 2553, 6290, 2012, 2336, 3189],
|
||||
[ 1700, 3677, 828, 4982, 2185, 3315, 2827, 2260, 1725, 4090, 503, 1050, 697, 606, 1253, 1765, 3851, 2666, 3588, 1547, 1387, 1401, 0, 3621, 903, 4675, 3537, 2954, 2475, 3169, 2427, 2254, 1578, 1148, 5177, 2598, 3521, 2194, 1833, 1074, 2054, 3340, 3423, 2541, 5213, 1801, 1077, 2190],
|
||||
[ 5279, 2863, 4136, 2322, 1860, 6199, 6009, 5840, 5346, 922, 3841, 4357, 3076, 3078, 4716, 4960, 6433, 5882, 6393, 4333, 2905, 4781, 3621, 0, 2718, 2042, 6254, 6024, 2569, 5966, 5913, 1687, 4807, 3384, 1716, 5699, 6384, 5787, 1852, 4687, 4285, 1272, 6022, 5892, 1629, 5178, 3581, 1639],
|
||||
[ 2578, 3106, 1518, 4178, 1401, 3932, 3552, 3141, 2628, 3207, 1196, 1770, 533, 419, 2072, 2444, 4372, 3401, 4183, 2019, 1062, 2166, 903, 2718, 0, 3864, 4097, 3635, 1932, 3748, 3274, 1448, 2284, 1164, 4286, 3283, 4136, 3086, 967, 1973, 2285, 2507, 3935, 3331, 4312, 2589, 1284, 1340],
|
||||
[ 6076, 1850, 4873, 320, 2491, 7745, 7412, 6596, 6285, 1131, 5054, 5633, 4363, 4070, 5915, 5443, 8098, 7263, 7977, 5817, 4482, 5427, 4675, 2042, 3864, 0, 7866, 7483, 2515, 7539, 7101, 3449, 6146, 3938, 1375, 7134, 7944, 6831, 3349, 5709, 4397, 1363, 7667, 7190, 1798, 6446, 5041, 2528],
|
||||
[ 3465, 7173, 3954, 8186, 5486, 365, 1104, 3563, 3007, 7014, 3042, 2498, 3567, 4052, 2454, 4396, 370, 1233, 202, 2079, 3398, 3984, 3537, 6254, 4097, 7866, 0, 839, 5973, 374, 2019, 4569, 1996, 4669, 7970, 1085, 305, 2581, 4532, 2976, 5339, 6509, 287, 1581, 7844, 1974, 2838, 5369],
|
||||
[ 2654, 6630, 3254, 7800, 5035, 482, 267, 2728, 2193, 6714, 2488, 1907, 3122, 3517, 1764, 3610, 1206, 399, 767, 1694, 3119, 3212, 2954, 6024, 3635, 7483, 839, 0, 5427, 558, 1181, 4349, 1377, 4044, 7723, 356, 653, 1744, 4218, 2241, 4614, 6121, 955, 743, 7644, 1231, 2465, 4957],
|
||||
[ 3625, 1204, 2446, 2778, 894, 5774, 5300, 4120, 3889, 2437, 2945, 3520, 2453, 1923, 3710, 2932, 6267, 5138, 6041, 3910, 2922, 2946, 2475, 2569, 1932, 2515, 5973, 5427, 0, 5612, 4824, 2550, 4050, 1498, 3476, 5071, 5980, 4470, 2096, 3388, 1911, 1501, 5831, 4994, 3704, 4264, 3209, 1196],
|
||||
[ 3115, 6814, 3581, 7859, 5141, 261, 821, 3240, 2661, 6707, 2676, 2128, 3219, 3690, 2082, 4034, 726, 923, 438, 1733, 3087, 3620, 3169, 5966, 3748, 7539, 374, 558, 5612, 0, 1716, 4280, 1624, 4298, 7679, 735, 420, 2263, 4216, 2606, 4967, 6179, 400, 1277, 7567, 1609, 2501, 5032],
|
||||
[ 1574, 6001, 2441, 7408, 4611, 1659, 916, 1559, 1122, 6477, 2087, 1558, 2842, 3032, 1204, 2572, 2384, 794, 1932, 1813, 3115, 2224, 2427, 5913, 3274, 7101, 2019, 1181, 4824, 1716, 0, 4330, 1180, 3346, 7545, 1023, 1808, 578, 4062, 1438, 3693, 5763, 2115, 440, 7537, 763, 2404, 4603],
|
||||
[ 3951, 3447, 2960, 3763, 1669, 4513, 4348, 4507, 3920, 2476, 2331, 2778, 1592, 1866, 3164, 3891, 4754, 4227, 4706, 2668, 1240, 3603, 2254, 1687, 1448, 3449, 4569, 4349, 2550, 4280, 4330, 0, 3184, 2510, 3402, 4031, 4698, 4281, 533, 3245, 3612, 2187, 4339, 4265, 3296, 3576, 1941, 1381],
|
||||
[ 1748, 5253, 1966, 6461, 3677, 1746, 1270, 2082, 1372, 5432, 1114, 531, 1791, 2142, 497, 2525, 2335, 1117, 2027, 654, 1953, 2089, 1578, 4807, 2284, 6146, 1996, 1377, 4050, 1624, 1180, 3184, 0, 2685, 6475, 1022, 1952, 1341, 2963, 1050, 3358, 4787, 1926, 1086, 6436, 422, 1244, 3619],
|
||||
[ 2142, 2656, 950, 4223, 1590, 4431, 3890, 2658, 2391, 3599, 1650, 2171, 1480, 838, 2287, 1590, 4991, 3724, 4711, 2694, 2175, 1496, 1148, 3384, 1164, 3938, 4669, 4044, 1498, 4298, 3346, 2510, 2685, 0, 4697, 3693, 4636, 2975, 1981, 1909, 1124, 2718, 4565, 3548, 4830, 2839, 2140, 1751],
|
||||
[ 6755, 3123, 5564, 1427, 3113, 7910, 7698, 7304, 6883, 1102, 5459, 6003, 4706, 4593, 6342, 6278, 8148, 7565, 8107, 6029, 4607, 6178, 5177, 1716, 4286, 1375, 7970, 7723, 3476, 7679, 7545, 3402, 6475, 4697, 0, 7393, 8097, 7370, 3515, 6249, 5379, 2001, 7738, 7556, 461, 6829, 5267, 3013],
|
||||
[ 2383, 6274, 2916, 7451, 4682, 769, 332, 2512, 1927, 6376, 2132, 1552, 2772, 3161, 1419, 3313, 1452, 286, 1061, 1366, 2796, 2906, 2598, 5699, 3283, 7134, 1085, 356, 5071, 735, 1023, 4031, 1022, 3693, 7393, 0, 965, 1542, 3883, 1913, 4286, 5772, 1121, 600, 7322, 902, 2128, 4608],
|
||||
[ 3306, 7183, 3878, 8263, 5533, 207, 900, 3364, 2845, 7121, 3037, 2472, 3610, 4060, 2379, 4261, 609, 1049, 132, 2130, 3501, 3861, 3521, 6384, 4136, 7944, 305, 653, 5980, 420, 1808, 4698, 1952, 4636, 8097, 965, 0, 2380, 4629, 2877, 5250, 6583, 570, 1380, 7986, 1866, 2904, 5432],
|
||||
[ 1029, 5622, 2035, 7131, 4352, 2225, 1484, 985, 611, 6284, 1958, 1538, 2721, 2788, 1134, 2033, 2949, 1348, 2503, 1991, 3119, 1719, 2194, 5787, 3086, 6831, 2581, 1744, 4470, 2263, 578, 4281, 1341, 2975, 7370, 1542, 2380, 0, 3952, 1127, 3197, 5518, 2658, 1002, 7395, 951, 2429, 4380],
|
||||
[ 3530, 3085, 2482, 3669, 1252, 4435, 4185, 4091, 3543, 2497, 1997, 2506, 1232, 1380, 2867, 3398, 4752, 4051, 4652, 2525, 1136, 3132, 1833, 1852, 967, 3349, 4532, 4218, 2096, 4216, 4062, 533, 2963, 1981, 3515, 3883, 4629, 3952, 0, 2873, 3080, 2012, 4324, 4046, 3478, 3328, 1755, 1000],
|
||||
[ 825, 4564, 1027, 6011, 3227, 2681, 2049, 1319, 676, 5160, 931, 791, 1656, 1663, 554, 1476, 3331, 1881, 2972, 1474, 2173, 1040, 1074, 4687, 1973, 5709, 2976, 2241, 3388, 2606, 1438, 3245, 1050, 1909, 6249, 1913, 2877, 1127, 2873, 0, 2374, 4392, 2943, 1659, 6285, 1012, 1563, 3254],
|
||||
[ 2188, 2756, 1395, 4638, 2426, 5053, 4415, 2544, 2590, 4318, 2513, 2912, 2550, 1932, 2885, 1241, 5687, 4248, 5344, 3542, 3268, 1479, 2054, 4285, 2285, 4397, 5339, 4614, 1911, 4967, 3693, 3612, 3358, 1124, 5379, 4286, 5250, 3197, 3080, 2374, 0, 3386, 5284, 3997, 5585, 3386, 3125, 2664],
|
||||
[ 4820, 1591, 3617, 1681, 1169, 6384, 6051, 5358, 4993, 937, 3701, 4277, 3001, 2736, 4569, 4287, 6746, 5903, 6617, 4455, 3136, 4211, 3340, 1272, 2507, 1363, 6509, 6121, 1501, 6179, 5763, 2187, 4787, 2718, 2001, 5772, 6583, 5518, 2012, 4392, 3386, 0, 6314, 5837, 2205, 5095, 3680, 1169],
|
||||
[ 3489, 7027, 3891, 7987, 5313, 550, 1219, 3632, 3039, 6795, 2923, 2403, 3403, 3915, 2405, 4390, 437, 1322, 486, 1923, 3189, 3969, 3423, 6022, 3935, 7667, 287, 955, 5831, 400, 2115, 4339, 1926, 4565, 7738, 1121, 570, 2658, 4324, 2943, 5284, 6314, 0, 1676, 7603, 1964, 2662, 5184],
|
||||
[ 1947, 6186, 2686, 7502, 4706, 1224, 482, 1987, 1486, 6507, 2137, 1564, 2860, 3138, 1289, 2928, 1948, 355, 1501, 1641, 3029, 2553, 2541, 5892, 3331, 7190, 1581, 743, 4994, 1277, 440, 4265, 1086, 3548, 7556, 600, 1380, 1002, 4046, 1659, 3997, 5837, 1676, 0, 7521, 744, 2325, 4670],
|
||||
[ 6835, 3472, 5661, 1877, 3241, 7805, 7635, 7391, 6934, 1268, 5459, 5983, 4697, 4647, 6338, 6419, 8005, 7508, 7989, 5957, 4527, 6290, 5213, 1629, 4312, 1798, 7844, 7644, 3704, 7567, 7537, 3296, 6436, 4830, 461, 7322, 7986, 7395, 3478, 6285, 5585, 2205, 7603, 7521, 0, 6805, 5208, 3102],
|
||||
[ 1542, 5461, 2023, 6758, 3962, 1670, 1054, 1785, 1112, 5773, 1394, 827, 2126, 2395, 555, 2428, 2334, 887, 1962, 1071, 2355, 2012, 1801, 5178, 2589, 6446, 1974, 1231, 4264, 1609, 763, 3576, 422, 2839, 6829, 902, 1866, 951, 3328, 1012, 3386, 5095, 1964, 744, 6805, 0, 1644, 3928],
|
||||
[ 2379, 4390, 1867, 5360, 2651, 2704, 2432, 2879, 2196, 4249, 711, 892, 756, 1351, 1297, 2749, 3098, 2302, 2939, 777, 711, 2336, 1077, 3581, 1284, 5041, 2838, 2465, 3209, 2501, 2404, 1941, 1244, 2140, 5267, 2128, 2904, 2429, 1755, 1563, 3125, 3680, 2662, 2325, 5208, 1644, 0, 2532],
|
||||
[ 3744, 2088, 2560, 2844, 304, 5230, 4884, 4296, 3876, 1914, 2534, 3109, 1836, 1592, 3406, 3337, 5618, 4736, 5469, 3302, 2042, 3189, 2190, 1639, 1340, 2528, 5369, 4957, 1196, 5032, 4603, 1381, 3619, 1751, 3013, 4608, 5432, 4380, 1000, 3254, 2664, 1169, 5184, 4670, 3102, 3928, 2532, 0],
|
||||
]
|
||||
|
||||
|
||||
# dmatrix = [
|
||||
# [0, 4, INF, 10],
|
||||
# [4, 0, 50, 20],
|
||||
# [INF, 50, 0, 3],
|
||||
# [10, 20, 3, 0],
|
||||
# ]
|
||||
|
||||
|
||||
# # # p01_d.txt
|
||||
# dmatrix = [
|
||||
# [0, 29, 82, 46, 68, 52, 72, 42, 51, 55, 29, 74, 23, 72, 46],
|
||||
# [29, 0, 55, 46, 42, 43, 43, 23, 23, 31, 41, 51, 11, 52, 21],
|
||||
# [82, 55, 0, 68, 46, 55, 23, 43, 41, 29, 79, 21, 64, 31, 51],
|
||||
# [46, 46, 68, 0, 82, 15, 72, 31, 62, 42, 21, 51, 51, 43, 64],
|
||||
# [68, 42, 46, 82, 0, 74, 23, 52, 21, 46, 82, 58, 46, 65, 23],
|
||||
# [52, 43, 55, 15, 74, 0, 61, 23, 55, 31, 33, 37, 51, 29, 59],
|
||||
# [72, 43, 23, 72, 23, 61, 0, 42, 23, 31, 77, 37, 51, 46, 33],
|
||||
# [42, 23, 43, 31, 52, 23, 42, 0, 33, 15, 37, 33, 33, 31, 37],
|
||||
# [51, 23, 41, 62, 21, 55, 23, 33, 0, 29, 62, 46, 29, 51, 11],
|
||||
# [55, 31, 29, 42, 46, 31, 31, 15, 29, 0, 51, 21, 41, 23, 37],
|
||||
# [29, 41, 79, 21, 82, 33, 77, 37, 62, 51, 0, 65, 42, 59, 61],
|
||||
# [74, 51, 21, 51, 58, 37, 37, 33, 46, 21, 65, 0, 61, 11, 55],
|
||||
# [23, 11, 64, 51, 46, 51, 51, 33, 29, 41, 42, 61, 0, 62, 23],
|
||||
# [72, 52, 31, 43, 65, 29, 46, 31, 51, 23, 59, 11, 62, 0, 59],
|
||||
# [46, 21, 51, 64, 23, 59, 33, 37, 11, 37, 61, 55, 23, 59, 0],
|
||||
# ]
|
||||
|
||||
|
||||
# # #five_d.txt
|
||||
# dmatrix = [
|
||||
# [0.0, 3.0, 4.0, 2.0, 7.0],
|
||||
# [3.0, 0.0, 4.0, 6.0, 3.0],
|
||||
# [4.0, 4.0, 0.0, 5.0, 8.0],
|
||||
# [2.0, 6.0, 5.0, 0.0, 6.0],
|
||||
# [7.0, 3.0, 8.0, 6.0, 0.0],
|
||||
# ]
|
||||
|
||||
|
||||
# # #gr17_d.txt
|
||||
# dmatrix = [
|
||||
# [ 0, 633, 257, 91, 412, 150, 80, 134, 259, 505, 353, 324, 70, 211, 268, 246, 121],
|
||||
# [ 633, 0, 390, 661, 227, 488, 572, 530, 555, 289, 282, 638, 567, 466, 420, 745, 518],
|
||||
# [ 257, 390, 0, 228, 169, 112, 196, 154, 372, 262, 110, 437, 191, 74, 53, 472, 142],
|
||||
# [ 91, 661, 228, 0, 383, 120, 77, 105, 175, 476, 324, 240, 27, 182, 239, 237, 84],
|
||||
# [ 412, 227, 169, 383, 0, 267, 351, 309, 338, 196, 61, 421, 346, 243, 199, 528, 297],
|
||||
# [ 150, 488, 112, 120, 267, 0, 63, 34, 264, 360, 208, 329, 83, 105, 123, 364, 35],
|
||||
# [ 80, 572, 196, 77, 351, 63, 0, 29, 232, 444, 292, 297, 47, 150, 207, 332, 29],
|
||||
# [ 134, 530, 154, 105, 309, 34, 29, 0, 249, 402, 250, 314, 68, 108, 165, 349, 36],
|
||||
# [ 259, 555, 372, 175, 338, 264, 232, 249, 0, 495, 352, 95, 189, 326, 383, 202, 236],
|
||||
# [ 505, 289, 262, 476, 196, 360, 444, 402, 495, 0, 154, 578, 439, 336, 240, 685, 390],
|
||||
# [ 353, 282, 110, 324, 61, 208, 292, 250, 352, 154, 0, 435, 287, 184, 140, 542, 238],
|
||||
# [ 324, 638, 437, 240, 421, 329, 297, 314, 95, 578, 435, 0, 254, 391, 448, 157, 301],
|
||||
# [ 70, 567, 191, 27, 346, 83, 47, 68, 189, 439, 287, 254, 0, 145, 202, 289, 55],
|
||||
# [ 211, 466, 74, 182, 243, 105, 150, 108, 326, 336, 184, 391, 145, 0, 57, 426, 96],
|
||||
# [ 268, 420, 53, 239, 199, 123, 207, 165, 383, 240, 140, 448, 202, 57, 0, 483, 153],
|
||||
# [ 246, 745, 472, 237, 528, 364, 332, 349, 202, 685, 542, 157, 289, 426, 483, 0, 336],
|
||||
# [ 121, 518, 142, 84, 297, 35, 29, 36, 236, 390, 238, 301, 55, 96, 153, 336, 0],
|
||||
# ]
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,206 @@
|
||||
|
||||
|
||||
def getAgvStop(stop):
|
||||
curStop = "01-112-3"
|
||||
if stop > 0:
|
||||
if 4000 <= stop:
|
||||
# charge stop
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 50 > stop:
|
||||
# main stop
|
||||
stopStr = ("{}".format(stop)).zfill(2)
|
||||
curStop = "{}-0000".format(stopStr)
|
||||
print(curStop)
|
||||
elif 100 > stop:
|
||||
# connection area
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
else:
|
||||
subStop = int(stop / 100)
|
||||
if 1 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 2 == subStop or 3 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "02-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 4 == subStop or 5 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "03-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 6 == subStop or 7 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "04-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 8 == subStop or 9 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "05-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 10 == subStop or 11 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "06-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 12 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "07-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 14 == subStop or 15 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "08-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 16 == subStop or 17 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "09-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 18 == subStop or 19 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "10-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 20 == subStop or 21 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "11-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
return curStop
|
||||
|
||||
'''
|
||||
start = "01-0112-3"
|
||||
end = "02-0311-2"
|
||||
'''
|
||||
def genPath(start, end):
|
||||
print("start {}, end {}".format(start, end))
|
||||
startParts = start.split("-")
|
||||
endParts = end.split("-")
|
||||
|
||||
if endParts[0] != startParts[0]:
|
||||
#cross stop
|
||||
startMainStop = int(startParts[0])
|
||||
stopMainStop = int(endParts[0])
|
||||
startMain = [startMainStop, stopMainStop]
|
||||
# startMain = []
|
||||
# if startMainStop > stopMainStop:
|
||||
# startMain = [x for x in range(startMainStop, stopMainStop - 1, -1)]
|
||||
# else:
|
||||
# startMain = [x for x in range(startMainStop, stopMainStop + 1)]
|
||||
|
||||
|
||||
startStop = int(startParts[1])
|
||||
if startStop >= 4000:
|
||||
halfPath1 = [startStop, 4000]
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
halfPath1 = [startStop, 63, 62, 61, 60]
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath1 = [x for x in range(startStop, 59, -1)]
|
||||
elif startStop > 0:
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
# halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
halfPath1 = [startStop, crossStop1]
|
||||
else:
|
||||
halfPath1 = []
|
||||
|
||||
|
||||
endStop = int(endParts[1])
|
||||
if endStop >= 4000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [4000, 4001, endStop]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
halfPath2 = [60, 61, 62, 63, endStop]
|
||||
elif endStop > 0:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
# halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
halfPath2 = [crossStop2, endStop]
|
||||
else:
|
||||
halfPath2 = []
|
||||
|
||||
return halfPath1 + startMain + halfPath2
|
||||
|
||||
elif endParts[0] == startParts[0]:
|
||||
# in same passway
|
||||
endStop = int(endParts[1])
|
||||
startStop = int(startParts[1])
|
||||
if endStop == startStop and 0 != startStop:
|
||||
# need to be done
|
||||
#same stop
|
||||
return [startStop]
|
||||
elif endStop == startStop and 0 == startStop:
|
||||
return [ int(startParts[0]) ]
|
||||
else:
|
||||
|
||||
if abs( endStop - startStop ) < 100 and endStop > 100 and startStop > 100:
|
||||
#don't include connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
else:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop < 100 and endStop > 50 and startStop < 100 and startStop > 50:
|
||||
#connection area
|
||||
# in same line
|
||||
if endStop > startStop > 63:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
elif endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
elif 63 < endStop < startStop:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
elif endStop < startStop:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop >= 4000 and startStop >= 4000:
|
||||
#Charge stop
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
else:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
|
||||
else:
|
||||
|
||||
if startStop >= 4000:
|
||||
#charge stop
|
||||
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
halfPath1 = [startStop, 4000]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath1 = [x for x in range(startStop, 59, -1)]
|
||||
halfPath1 = [startStop, 63, 62, 61, 60]
|
||||
elif startStop > 0:
|
||||
# cross line
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
# halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
halfPath1 = [startStop, crossStop1]
|
||||
else:
|
||||
halfPath1 = []
|
||||
|
||||
if endStop >= 4000:
|
||||
#charge stop
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [4000, endStop]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
halfPath2 = [60, 61, 62, 63, endStop]
|
||||
elif endStop > 0:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
# halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
halfPath2 = [crossStop2, endStop]
|
||||
else:
|
||||
halfPath2 = []
|
||||
# print("halfPath1 {}, startParts[0] {}, halfPath2 {}".format(halfPath1, startParts[0], halfPath2))
|
||||
|
||||
return halfPath1 + [ int(startParts[0]) ] + halfPath2
|
@ -0,0 +1,176 @@
|
||||
|
||||
|
||||
def getAgvStop(stop):
|
||||
curStop = "01-112-3"
|
||||
if stop > 0:
|
||||
if 4000 <= stop:
|
||||
# charge stop
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 50 > stop:
|
||||
# main stop
|
||||
stopStr = ("{}".format(stop)).zfill(2)
|
||||
curStop = "{}-0000".format(stopStr)
|
||||
print(curStop)
|
||||
elif 100 > stop:
|
||||
# connection area
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
else:
|
||||
subStop = int(stop / 100)
|
||||
if 1 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 2 == subStop or 3 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "02-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 4 == subStop or 5 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "03-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 6 == subStop or 7 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "04-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 8 == subStop or 9 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "05-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 10 == subStop or 11 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "06-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 12 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "07-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 14 == subStop or 15 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "08-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 16 == subStop or 17 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "09-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 18 == subStop or 19 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "10-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 20 == subStop or 21 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "11-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
return curStop
|
||||
|
||||
'''
|
||||
start = "01-0112-3"
|
||||
end = "02-0311-2"
|
||||
'''
|
||||
def genPath(start, end):
|
||||
print("start {}, end{}".format(start, end))
|
||||
startParts = start.split("-")
|
||||
endParts = end.split("-")
|
||||
|
||||
if endParts[0] != startParts[0]:
|
||||
#cross stop
|
||||
startMainStop = int(startParts[0])
|
||||
stopMainStop = int(endParts[0])
|
||||
|
||||
startMain = []
|
||||
if startMainStop > stopMainStop:
|
||||
startMain = [x for x in range(startMainStop, stopMainStop - 1, -1)]
|
||||
else:
|
||||
startMain = [x for x in range(startMainStop, stopMainStop + 1)]
|
||||
|
||||
|
||||
startStop = int(startParts[1])
|
||||
if startStop >= 4000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
halfPath1 = [x for x in range(startStop, 69)]
|
||||
else:
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
|
||||
endStop = int(endParts[1])
|
||||
if endStop >= 4000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
else:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
|
||||
return halfPath1 + startMain + halfPath2
|
||||
|
||||
elif endParts[0] == startParts[0]:
|
||||
# in same passway
|
||||
endStop = int(endParts[1])
|
||||
startStop = int(startParts[1])
|
||||
if endStop == startStop and 0 != startStop:
|
||||
# need to be done
|
||||
#same stop
|
||||
return [startStop]
|
||||
elif endStop == startStop and 0 == startStop:
|
||||
return [ int(startParts[0]) ]
|
||||
else:
|
||||
|
||||
if abs( endStop - startStop ) < 100 and endStop > 100 and startStop > 100:
|
||||
#don't include connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
else:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop < 100 and endStop > 50 and startStop < 100 and startStop > 50:
|
||||
#connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
else:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop >= 4000 and startStop >= 4000:
|
||||
#Charge stop
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
else:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
else:
|
||||
|
||||
if startStop >= 4000:
|
||||
#charge stop
|
||||
halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
halfPath1 = [x for x in range(startStop, 69)]
|
||||
else:
|
||||
# cross line
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
|
||||
|
||||
if endStop >= 4000:
|
||||
#charge stop
|
||||
halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
else:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
|
||||
# print("halfPath1 {}, startParts[0] {}, halfPath2 {}".format(halfPath1, startParts[0], halfPath2))
|
||||
|
||||
return halfPath1 + [ int(startParts[0]) ] + halfPath2
|
@ -0,0 +1,150 @@
|
||||
|
||||
|
||||
def getAgvStop(stop):
|
||||
curStop = "01-112-3"
|
||||
if stop > 0:
|
||||
if 50 > stop:
|
||||
# main stop
|
||||
stopStr = ("{}".format(stop)).zfill(2)
|
||||
curStop = "{}-0000".format(stopStr)
|
||||
print(curStop)
|
||||
elif 100 > stop:
|
||||
# connection area
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
else:
|
||||
subStop = int(stop / 100)
|
||||
if 1 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 2 == subStop or 3 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "02-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 4 == subStop or 5 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "03-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 6 == subStop or 7 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "04-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 8 == subStop or 9 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "05-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 10 == subStop or 11 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "06-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 12 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "07-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 14 == subStop or 15 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "08-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 16 == subStop or 17 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "09-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 18 == subStop or 19 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "10-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 20 == subStop or 21 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "11-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
return curStop
|
||||
|
||||
'''
|
||||
start = "01-0112-3"
|
||||
end = "02-0311-2"
|
||||
'''
|
||||
def genPath(start, end):
|
||||
|
||||
startParts = start.split("-")
|
||||
endParts = end.split("-")
|
||||
|
||||
if endParts[0] != startParts[0]:
|
||||
#cross stop
|
||||
startMainStop = int(startParts[0])
|
||||
stopMainStop = int(endParts[0])
|
||||
|
||||
startMain = []
|
||||
if startMainStop > stopMainStop:
|
||||
startMain = [x for x in range(startMainStop, stopMainStop - 1, -1)]
|
||||
else:
|
||||
startMain = [x for x in range(startMainStop, stopMainStop + 1)]
|
||||
|
||||
|
||||
startStop = int(startParts[1])
|
||||
#connection area stop number start from 60 to 76
|
||||
if 50 < startStop and 100 > startStop:
|
||||
halfPath1 = [x for x in range(startStop, 77)]
|
||||
else:
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
|
||||
endStop = int(endParts[1])
|
||||
#connection area stop number start from 60 to 76
|
||||
if 50 < endStop and 100 > endStop:
|
||||
halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
else:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
|
||||
return halfPath1 + startMain + halfPath2
|
||||
|
||||
elif endParts[0] == startParts[0]:
|
||||
# in same passway
|
||||
endStop = int(endParts[1])
|
||||
startStop = int(startParts[1])
|
||||
if endStop == startStop and 0 != startStop:
|
||||
# need to be done
|
||||
#same stop
|
||||
return [startStop]
|
||||
elif endStop == startStop and 0 == startStop:
|
||||
return [ int(startParts[0]) ]
|
||||
else:
|
||||
if abs( endStop - startStop ) < 100 and endStop > 100 and startStop > 100:
|
||||
#don't include connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
else:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop < 100 and endStop > 50 and startStop < 100 and startStop > 50:
|
||||
#don't include connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
else:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
else:
|
||||
|
||||
|
||||
#connection area stop number start from 60 to 76
|
||||
if 50 < startStop and 100 > startStop:
|
||||
halfPath1 = [x for x in range(startStop, 77)]
|
||||
else:
|
||||
# cross line
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
|
||||
#connection area stop number start from 60 to 76
|
||||
if 50 < endStop and 100 > endStop:
|
||||
halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
else:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
|
||||
# print("halfPath1 {}, startParts[0] {}, halfPath2 {}".format(halfPath1, startParts[0], halfPath2))
|
||||
|
||||
return halfPath1 + [ int(startParts[0]) ] + halfPath2
|
@ -0,0 +1,219 @@
|
||||
|
||||
|
||||
def getAgvStop(stop):
|
||||
curStop = "01-112-3"
|
||||
if stop > 0:
|
||||
if 4000 <= stop:
|
||||
# charge stop
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 50 > stop:
|
||||
# main stop
|
||||
stopStr = ("{}".format(stop)).zfill(2)
|
||||
curStop = "{}-0000".format(stopStr)
|
||||
print(curStop)
|
||||
elif 100 > stop:
|
||||
# connection area
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
else:
|
||||
subStop = int(stop / 100)
|
||||
if 1 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 2 == subStop or 3 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "02-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 4 == subStop or 5 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "03-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 6 == subStop or 7 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "04-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 8 == subStop or 9 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "05-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 10 == subStop or 11 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "06-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 12 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "07-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 14 == subStop or 15 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "08-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 16 == subStop or 17 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "09-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 18 == subStop or 19 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "10-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 20 == subStop or 21 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "11-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
return curStop
|
||||
|
||||
'''
|
||||
start = "01-0112-3"
|
||||
end = "02-0311-2"
|
||||
'''
|
||||
def genPath(start, end):
|
||||
print("start {}, end {}".format(start, end))
|
||||
startParts = start.split("-")
|
||||
endParts = end.split("-")
|
||||
|
||||
if endParts[0] != startParts[0]:
|
||||
#cross stop
|
||||
startMainStop = int(startParts[0])
|
||||
stopMainStop = int(endParts[0])
|
||||
startMain = [startMainStop, stopMainStop]
|
||||
# startMain = []
|
||||
# if startMainStop > stopMainStop:
|
||||
# startMain = [x for x in range(startMainStop, stopMainStop - 1, -1)]
|
||||
# else:
|
||||
# startMain = [x for x in range(startMainStop, stopMainStop + 1)]
|
||||
|
||||
|
||||
startStop = int(startParts[1])
|
||||
if startStop >= 5000:
|
||||
halfPath1 = [startStop, 5003, 5002, 5001, 5000]
|
||||
elif startStop >= 4000:
|
||||
halfPath1 = [startStop, 4000]
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
halfPath1 = [startStop, 63, 62, 61, 60]
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath1 = [x for x in range(startStop, 59, -1)]
|
||||
elif startStop > 0:
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
# halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
halfPath1 = [startStop, crossStop1]
|
||||
else:
|
||||
halfPath1 = []
|
||||
|
||||
|
||||
endStop = int(endParts[1])
|
||||
if endStop >= 5000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [5000, 5001, 5002, 5003, endStop]
|
||||
elif endStop >= 4000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [4000, 4001, endStop]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
halfPath2 = [60, 61, 62, 63, endStop]
|
||||
elif endStop > 0:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
# halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
halfPath2 = [crossStop2, endStop]
|
||||
else:
|
||||
halfPath2 = []
|
||||
|
||||
return halfPath1 + startMain + halfPath2
|
||||
|
||||
elif endParts[0] == startParts[0]:
|
||||
# in same passway
|
||||
endStop = int(endParts[1])
|
||||
startStop = int(startParts[1])
|
||||
if endStop == startStop and 0 != startStop:
|
||||
# need to be done
|
||||
#same stop
|
||||
return [startStop]
|
||||
elif endStop == startStop and 0 == startStop:
|
||||
return [ int(startParts[0]) ]
|
||||
else:
|
||||
|
||||
if abs( endStop - startStop ) < 100 and endStop > 100 and startStop > 100:
|
||||
#don't include connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
else:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop < 100 and endStop > 50 and startStop < 100 and startStop > 50:
|
||||
#connection area
|
||||
# in same line
|
||||
if endStop > startStop > 63:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
elif endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
elif 63 < endStop < startStop:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
elif endStop < startStop:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop >= 4000 and startStop >= 4000:
|
||||
#Charge stop
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
else:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
|
||||
else:
|
||||
if startStop >= 5000:
|
||||
#charge stop
|
||||
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
halfPath1 = [startStop, 5003, 5002, 5001, 5000]
|
||||
elif startStop >= 4000:
|
||||
#charge stop
|
||||
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
halfPath1 = [startStop, 4000]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath1 = [x for x in range(startStop, 59, -1)]
|
||||
halfPath1 = [startStop, 63, 62, 61, 60]
|
||||
elif startStop > 0:
|
||||
# cross line
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
# halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
halfPath1 = [startStop, crossStop1]
|
||||
else:
|
||||
halfPath1 = []
|
||||
|
||||
if endStop >= 5000:
|
||||
#charge stop
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [5000, 5001, 5002, 5003, endStop]
|
||||
elif endStop >= 4000:
|
||||
#charge stop
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [4000, endStop]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
halfPath2 = [60, 61, 62, 63, endStop]
|
||||
elif endStop > 0:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
# halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
halfPath2 = [crossStop2, endStop]
|
||||
else:
|
||||
halfPath2 = []
|
||||
# print("halfPath1 {}, startParts[0] {}, halfPath2 {}".format(halfPath1, startParts[0], halfPath2))
|
||||
|
||||
return halfPath1 + [ int(startParts[0]) ] + halfPath2
|
@ -0,0 +1,176 @@
|
||||
|
||||
|
||||
def getAgvStop(stop):
|
||||
curStop = "01-112-3"
|
||||
if stop > 0:
|
||||
if 4000 <= stop:
|
||||
# charge stop
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 50 > stop:
|
||||
# main stop
|
||||
stopStr = ("{}".format(stop)).zfill(2)
|
||||
curStop = "{}-0000".format(stopStr)
|
||||
print(curStop)
|
||||
elif 100 > stop:
|
||||
# connection area
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
else:
|
||||
subStop = int(stop / 100)
|
||||
if 1 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 2 == subStop or 3 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "02-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 4 == subStop or 5 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "03-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 6 == subStop or 7 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "04-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 8 == subStop or 9 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "05-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 10 == subStop or 11 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "06-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 12 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "07-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 14 == subStop or 15 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "08-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 16 == subStop or 17 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "09-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 18 == subStop or 19 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "10-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 20 == subStop or 21 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "11-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
return curStop
|
||||
|
||||
'''
|
||||
start = "01-0112-3"
|
||||
end = "02-0311-2"
|
||||
'''
|
||||
def genPath(start, end):
|
||||
print("start {}, end{}".format(start, end))
|
||||
startParts = start.split("-")
|
||||
endParts = end.split("-")
|
||||
|
||||
if endParts[0] != startParts[0]:
|
||||
#cross stop
|
||||
startMainStop = int(startParts[0])
|
||||
stopMainStop = int(endParts[0])
|
||||
|
||||
startMain = []
|
||||
if startMainStop > stopMainStop:
|
||||
startMain = [x for x in range(startMainStop, stopMainStop - 1, -1)]
|
||||
else:
|
||||
startMain = [x for x in range(startMainStop, stopMainStop + 1)]
|
||||
|
||||
|
||||
startStop = int(startParts[1])
|
||||
if startStop >= 4000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
halfPath1 = [x for x in range(startStop, 59, -1)]
|
||||
else:
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
|
||||
endStop = int(endParts[1])
|
||||
if endStop >= 4000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
else:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
|
||||
return halfPath1 + startMain + halfPath2
|
||||
|
||||
elif endParts[0] == startParts[0]:
|
||||
# in same passway
|
||||
endStop = int(endParts[1])
|
||||
startStop = int(startParts[1])
|
||||
if endStop == startStop and 0 != startStop:
|
||||
# need to be done
|
||||
#same stop
|
||||
return [startStop]
|
||||
elif endStop == startStop and 0 == startStop:
|
||||
return [ int(startParts[0]) ]
|
||||
else:
|
||||
|
||||
if abs( endStop - startStop ) < 100 and endStop > 100 and startStop > 100:
|
||||
#don't include connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
else:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop < 100 and endStop > 50 and startStop < 100 and startStop > 50:
|
||||
#connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
else:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop >= 4000 and startStop >= 4000:
|
||||
#Charge stop
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
else:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
else:
|
||||
|
||||
if startStop >= 4000:
|
||||
#charge stop
|
||||
halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
halfPath1 = [x for x in range(startStop, 59, -1)]
|
||||
else:
|
||||
# cross line
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
|
||||
|
||||
if endStop >= 4000:
|
||||
#charge stop
|
||||
halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
else:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
|
||||
# print("halfPath1 {}, startParts[0] {}, halfPath2 {}".format(halfPath1, startParts[0], halfPath2))
|
||||
|
||||
return halfPath1 + [ int(startParts[0]) ] + halfPath2
|
@ -0,0 +1,255 @@
|
||||
|
||||
|
||||
def getAgvStop(stop):
|
||||
curStop = "01-112-3"
|
||||
if stop > 0:
|
||||
if 4000 <= stop:
|
||||
# charge stop
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 50 > stop:
|
||||
# main stop
|
||||
stopStr = ("{}".format(stop)).zfill(2)
|
||||
curStop = "{}-0000".format(stopStr)
|
||||
print(curStop)
|
||||
elif 100 > stop:
|
||||
# connection area
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
else:
|
||||
subStop = int(stop / 100)
|
||||
if 1 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "01-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 2 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "02-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 3 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "03-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 4 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "04-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 5 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "05-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 6 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "06-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 7 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "07-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 8 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "08-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 9 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "09-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 10 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "10-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 11 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "11-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 12 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "12-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 14 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "13-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 15 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "14-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 16 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "15-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 17 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "16-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 18 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "17-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 19 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "18-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 20 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "19-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
elif 21 == subStop:
|
||||
stopStr = ("{}".format(stop)).zfill(4)
|
||||
curStop = "20-{}-1".format(stopStr)
|
||||
print(curStop)
|
||||
return curStop
|
||||
|
||||
'''
|
||||
start = "01-0112-3"
|
||||
end = "03-0311-2"
|
||||
'''
|
||||
def genPath(start, end):
|
||||
print("start {}, end {}".format(start, end))
|
||||
startParts = start.split("-")
|
||||
endParts = end.split("-")
|
||||
|
||||
if endParts[0] != startParts[0]:
|
||||
#cross stop
|
||||
startMainStop = int(startParts[0])
|
||||
stopMainStop = int(endParts[0])
|
||||
startMain = [startMainStop, stopMainStop]
|
||||
# startMain = []
|
||||
# if startMainStop > stopMainStop:
|
||||
# startMain = [x for x in range(startMainStop, stopMainStop - 1, -1)]
|
||||
# else:
|
||||
# startMain = [x for x in range(startMainStop, stopMainStop + 1)]
|
||||
|
||||
|
||||
startStop = int(startParts[1])
|
||||
if startStop >= 5000:
|
||||
halfPath1 = [startStop, 5002]
|
||||
elif startStop >= 4000:
|
||||
halfPath1 = [startStop, 4000]
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
halfPath1 = [startStop, 63]
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath1 = [x for x in range(startStop, 59, -1)]
|
||||
elif startStop > 0:
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
# halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
halfPath1 = [startStop, crossStop1]
|
||||
else:
|
||||
halfPath1 = []
|
||||
|
||||
|
||||
endStop = int(endParts[1])
|
||||
if endStop >= 5000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [5002, endStop]
|
||||
elif endStop >= 4000:
|
||||
#charge Stop 01 -> 4000 -> 4001 -> 4002
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [4000, 4001, endStop]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
halfPath2 = [63, endStop]
|
||||
elif endStop > 0:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
# halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
halfPath2 = [crossStop2, endStop]
|
||||
else:
|
||||
halfPath2 = []
|
||||
|
||||
return halfPath1 + startMain + halfPath2
|
||||
|
||||
elif endParts[0] == startParts[0]:
|
||||
# in same passway
|
||||
endStop = int(endParts[1])
|
||||
startStop = int(startParts[1])
|
||||
if endStop == startStop and 0 != startStop:
|
||||
# need to be done
|
||||
#same stop
|
||||
return [startStop]
|
||||
elif endStop == startStop and 0 == startStop:
|
||||
return [ int(startParts[0]) ]
|
||||
else:
|
||||
|
||||
if abs( endStop - startStop ) < 100 and endStop > 100 and startStop > 100:
|
||||
#don't include connection area
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
else:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop < 100 and endStop > 50 and startStop < 100 and startStop > 50:
|
||||
#connection area
|
||||
# in same line
|
||||
if endStop > startStop > 63:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
elif endStop > startStop:
|
||||
return [x for x in range(startStop, endStop + 1)]
|
||||
elif 63 < endStop < startStop:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
elif endStop < startStop:
|
||||
return [x for x in range(startStop, endStop - 1, -1)]
|
||||
|
||||
|
||||
elif abs( endStop - startStop ) < 100 and endStop >= 4000 and startStop >= 4000:
|
||||
#Charge stop
|
||||
# in same line
|
||||
if endStop > startStop:
|
||||
# return [x for x in range(startStop, endStop + 1)]
|
||||
return [startStop, endStop]
|
||||
else:
|
||||
# return [x for x in range(startStop, endStop - 1, -1)]
|
||||
return [startStop, endStop]
|
||||
|
||||
else:
|
||||
if startStop >= 5000:
|
||||
#charge stop
|
||||
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
halfPath1 = [startStop, 5002]
|
||||
elif startStop >= 4000:
|
||||
#charge stop
|
||||
# halfPath1 = [x for x in range(startStop, 3999, -1)]
|
||||
halfPath1 = [startStop, 4000]
|
||||
elif 50 < startStop and 100 > startStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath1 = [x for x in range(startStop, 59, -1)]
|
||||
halfPath1 = [startStop, 63]
|
||||
elif startStop > 0:
|
||||
# cross line
|
||||
crossStop1 = int(startStop / 100)*100 + 10
|
||||
# halfPath1 = [x for x in range(startStop, crossStop1 - 1, -1)]
|
||||
halfPath1 = [startStop, crossStop1]
|
||||
else:
|
||||
halfPath1 = []
|
||||
|
||||
if endStop >= 5000:
|
||||
#charge stop
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [5002, endStop]
|
||||
elif endStop >= 4000:
|
||||
#charge stop
|
||||
# halfPath2 = [x for x in range(4000, endStop + 1)]
|
||||
halfPath2 = [4000, endStop]
|
||||
elif 50 < endStop and 100 > endStop:
|
||||
#connection area stop number start from 60 to 68
|
||||
# halfPath2 = [x for x in range(60, endStop + 1)]
|
||||
halfPath2 = [63, endStop]
|
||||
elif endStop > 0:
|
||||
crossStop2 = int(endStop / 100)*100 + 10
|
||||
# halfPath2 = [x for x in range(crossStop2, endStop + 1)]
|
||||
halfPath2 = [crossStop2, endStop]
|
||||
else:
|
||||
halfPath2 = []
|
||||
# print("halfPath1 {}, startParts[0] {}, halfPath2 {}".format(halfPath1, startParts[0], halfPath2))
|
||||
|
||||
return halfPath1 + [ int(startParts[0]) ] + halfPath2
|
@ -0,0 +1,3 @@
|
||||
cd /d D:\AutoTaskSchedule\simAgv
|
||||
|
||||
python main.py --host 0.0.0.0 --reload
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
from .gxipy import gxipy
|
||||
# from .gxipy.gxidef import *
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,103 @@
|
||||
# labelMap = [
|
||||
# #Big x, y, x1, y1, Label, num, sign
|
||||
# [ 259.9213, -199.1091, 238.0209, -107.0088, "B1", 401, 1],#1
|
||||
# [ 118.2232, -113.7113, 133.223, -107.9106, "B2", 404, 1],#2
|
||||
# [ 298.0214, -9.1093, 242.2205, -0.7079, "B3", 402, 1],#3
|
||||
# [ 187.2214, -7.0099, 138.2216, -1.9102, "B4", 405, 1],#4
|
||||
# [ 298.4224, 93.9812, 246.2243, 106.5838, "B5", 403, 1],#5
|
||||
# [ 195.8225, 98.182, 141.224, 108.6835, "B6", 406, 1],#6
|
||||
# # #little
|
||||
# # [219.2259, -134.5134, 274.2259, -139.5131, "L1", 301, -1],#1
|
||||
# # [141.2238, -131.5109, 187.1251, -136.5126, "L2", 305, -1],#2
|
||||
# # # [, "L3", 309, -1],#3
|
||||
# # [225.2205, -44.5074, 277.2257, -51.5123, "L4", 302, -1],#4
|
||||
# # [139.2199, -44.5065, 190.0238, -48.612, "L5", 306, -1], #5
|
||||
# # # [, "L6", 310, -1],#6
|
||||
# # [228.7183, 40.4935, 284.5179, 40.4931, "L7", 303, -1],#7
|
||||
# # [142.4177, 40.4924, 198.2177, 42.5925, "L8", 307, -1],#8
|
||||
# # # [, "L9", 311, -1],#9
|
||||
# # [233.2122, 132.0875, 284.0166, 130.4906, "L10", 304, -1],#10
|
||||
# # # [, "L11", 308, -1],#11
|
||||
# # [145.0099, 132.0864, 196.1168, 132.5911, "L12", 312, -1],#12
|
||||
# #big disk
|
||||
# [12.2261, -215.5127, -44.7728, -205.5122, "BD1", 102, 1],#1
|
||||
# [-144.6989, -209.1089, -164.6981, -204.1083, "BD2", 101, 1],#2
|
||||
# #little disk
|
||||
# [45.8251, 147.7807, -4.1743, 149.881, "LD1", 205, 1],#1
|
||||
# [-42.3746, 145.6784, -92.3706, 154.079, "LD2", 203, 1],#2
|
||||
# [-130.5713, 151.79761, -180.57, 154.0777, "LD3", 201, 1],#3
|
||||
# [48.6326, 246.1763, -2.0666, 248.9752, "LD4", 206, 1],#4
|
||||
# [-39.5668, 248.2769, -89.1668, 253.9755, "LD5", 204, 1],#5
|
||||
# [-125.6693, 248.2777, -174.2673, 254.8755, "LD6", 202, 1],#6
|
||||
# ]
|
||||
|
||||
|
||||
#Ver 1.0 Backup
|
||||
# labelMapLittleBox = [
|
||||
# #little
|
||||
# [219.2259, -134.5134, 274.2259, -139.5131, "L1", 301, -1],#1
|
||||
# [141.2238, -131.5109, 187.1251, -136.5126, "L2", 305, -1],#2
|
||||
# # [, "L3", 309, -1],#3
|
||||
# [225.2205, -44.5074, 277.2257, -51.5123, "L4", 302, -1],#4
|
||||
# [139.2199, -44.5065, 190.0238, -48.612, "L5", 306, -1], #5
|
||||
# # [, "L6", 310, -1],#6
|
||||
# [228.7183, 40.4935, 284.5179, 40.4931, "L7", 303, -1],#7
|
||||
# [142.4177, 40.4924, 198.2177, 42.5925, "L8", 307, -1],#8
|
||||
# # [, "L9", 311, -1],#9
|
||||
# [233.2122, 132.0875, 284.0166, 130.4906, "L10", 304, -1],#10
|
||||
# # [, "L11", 308, -1],#11
|
||||
# [145.0099, 132.0864, 196.1168, 132.5911, "L12", 312, -1],#12
|
||||
# ]
|
||||
|
||||
# labelMapBigBox = [
|
||||
# #Big x, y, x1, y1, Label, num, sign
|
||||
# [ 259.9213, -199.1091, 238.0209, -107.0088, "B1", 401, 1],#1
|
||||
# [ 118.2232, -113.7113, 133.223, -107.9106, "B2", 404, 1],#2
|
||||
# [ 298.0214, -9.1093, 242.2205, -0.7079, "B3", 402, 1],#3
|
||||
# [ 187.2214, -7.0099, 138.2216, -1.9102, "B4", 405, 1],#4
|
||||
# [ 298.4224, 93.9812, 246.2243, 106.5838, "B5", 403, 1],#5
|
||||
# [ 195.8225, 98.182, 141.224, 108.6835, "B6", 406, 1],#6
|
||||
# ]
|
||||
|
||||
|
||||
labelMapBigDisk = [
|
||||
#big disk
|
||||
[12.2261, -215.5127, -44.7728, -205.5122, "BD1", 102, 1],#1
|
||||
[-144.6989, -209.1089, -164.6981, -204.1083, "BD2", 101, 1],#2
|
||||
]
|
||||
|
||||
labelMapLittleDisk = [
|
||||
#little disk
|
||||
[45.8251, 147.7807, -4.1743, 149.881, "LD1", 205, 1],#1
|
||||
[-42.3746, 145.6784, -92.3706, 154.079, "LD2", 203, 1],#2
|
||||
[-130.5713, 151.79761, -180.57, 154.0777, "LD3", 201, 1],#3
|
||||
[48.6326, 246.1763, -2.0666, 248.9752, "LD4", 206, 1],#4
|
||||
[-39.5668, 248.2769, -89.1668, 253.9755, "LD5", 204, 1],#5
|
||||
[-125.6693, 248.2777, -174.2673, 254.8755, "LD6", 202, 1],#6
|
||||
]
|
||||
|
||||
labelMapLittleBox = [
|
||||
#little
|
||||
[219.2259, -134.5134, 271.231, -139.5202, "L1", 301, -1],#1
|
||||
[141.2238, -131.5109, 187.1251, -136.5126, "L2", 305, -1],#2
|
||||
[159.2232, -140.5107, 100.2208, -131.5098, "L3", 309, -1],#3
|
||||
[225.2205, -44.5074, 273.2308, -52.5199, "L4", 302, -1],#4
|
||||
[139.2199, -44.5065, 190.0239, -48.6126, "L5", 306, -1], #5
|
||||
[163.2218, -52.5101, 108.2208, -41.5097, "L6", 310, -1],#6
|
||||
[228.7183, 40.4935, 279.5174, 33.4927, "L7", 303, -1],#7
|
||||
[142.4178, 40.4924, 198.2177, 42.5925, "L8", 307, -1],#8
|
||||
[171.016, 33.4849, 109.0145, 43.4882, "L9", 311, -1],#9
|
||||
[233.2122, 132.0875, 281.5174, 123.4922, "L10", 304, -1],#10
|
||||
[145.01, 132.0864, 196.1168, 132.5911, "L11", 308, -1],#11
|
||||
[174.0126, 124.4902, 112.0152, 132.4889, "L12", 312, -1],#12
|
||||
]
|
||||
|
||||
labelMapBigBox = [
|
||||
#Big x, y, x1, y1, Label, num, sign
|
||||
[ 259.9213, -119.1091, 238.0209, -107.0088, "B1", 401, 1],#1
|
||||
[ 188.2232, -113.7113, 137.2221, -103.9104, "B2", 404, 1],#2
|
||||
[ 298.0214, -9.1093, 242.2205, -0.7079, "B3", 402, 1],#3
|
||||
[ 187.2214, -7.0099, 141.2216, 1.0898, "B4", 405, 1],#4
|
||||
[ 298.4224, 93.9812, 246.2243, 106.5838, "B5", 403, 1],#5
|
||||
[ 195.8225, 98.182, 141.224, 108.6835, "B6", 406, 1],#6
|
||||
]
|
@ -0,0 +1,471 @@
|
||||
# version:1.1.2312.9221
|
||||
from . import gxipy as gx
|
||||
from PIL import Image
|
||||
from ctypes import *
|
||||
from .gxipy.gxidef import *
|
||||
import numpy
|
||||
from .gxipy.ImageFormatConvert import *
|
||||
from datetime import datetime
|
||||
|
||||
import cv2
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
import math
|
||||
import json
|
||||
|
||||
import pyzbar
|
||||
|
||||
from PIL import Image
|
||||
from pyzbar.pyzbar import decode, ZBarSymbol
|
||||
|
||||
|
||||
DX_RANGE = 5
|
||||
DY_RANGE = 5
|
||||
RADIUS_RANGE = 10
|
||||
|
||||
# MASK_RADIUS = 400
|
||||
MASK_RADIUS = 500
|
||||
|
||||
QRCODE = None
|
||||
|
||||
def nothing(x):
|
||||
# any operation
|
||||
pass
|
||||
|
||||
# '''
|
||||
# HoughLinesP:
|
||||
# threshold: The minimum number of intersections to "*detect*" a line
|
||||
# minLineLength: The minimum number of points that can form a line. Lines with less than this number of points are disregarded.
|
||||
# maxLineGap: The maximum gap between two points to be considered in the same line.
|
||||
# '''
|
||||
|
||||
# cv2.namedWindow("Trackbars", cv2.WINDOW_AUTOSIZE)
|
||||
|
||||
# cv2.createTrackbar("threshold", "Trackbars", 0, 255, nothing)
|
||||
# cv2.createTrackbar("minLineLength", "Trackbars", 0, 255, nothing)
|
||||
# cv2.createTrackbar("maxLineGap", "Trackbars", 0, 255, nothing)
|
||||
|
||||
|
||||
# '''
|
||||
# Canny:
|
||||
# threshold1 first threshold for the hysteresis procedure.
|
||||
# threshold2 second threshold for the hysteresis procedure.
|
||||
# apertureSize aperture size for the Sobel operator.
|
||||
# '''
|
||||
|
||||
# cv2.createTrackbar("threshold1", "Trackbars", 0, 255, nothing)
|
||||
# cv2.createTrackbar("threshold2", "Trackbars", 0, 255, nothing)
|
||||
# # cv2.createTrackbar("apertureSize", "Trackbars", 3, 7, nothing)
|
||||
|
||||
|
||||
|
||||
# cv2.namedWindow("CircleTrackbars", cv2.WINDOW_AUTOSIZE)
|
||||
|
||||
# '''
|
||||
# Hough Circle Transform:
|
||||
# Blur
|
||||
# param_1 = 200: Upper threshold for the internal Canny edge detector.
|
||||
# param_2 = 100*: Threshold for center detection.
|
||||
# min_radius = 0: Minimum radius to be detected. If unknown, put zero as default.
|
||||
# max_radius = 0: Maximum radius to be detected. If unknown, put zero as default.
|
||||
|
||||
# '''
|
||||
# cv2.createTrackbar("radius", "CircleTrackbars", 20, 255, nothing)
|
||||
# cv2.createTrackbar("blur", "CircleTrackbars", 5, 16, nothing)
|
||||
# cv2.createTrackbar("param_1", "CircleTrackbars", 300, 500, nothing)
|
||||
# cv2.createTrackbar("param_2", "CircleTrackbars", 36, 255, nothing)
|
||||
# cv2.createTrackbar("min_radius", "CircleTrackbars", 50, 255, nothing)
|
||||
# cv2.createTrackbar("max_radius", "CircleTrackbars", 255, 255, nothing)
|
||||
|
||||
|
||||
|
||||
# # font = cv2.FONT_HERSHEY_COMPLEX
|
||||
|
||||
# # fileName = "{}.avi".format(datetime.now().strftime("%Y_%m_%d_%H_%M_%S"))
|
||||
|
||||
# # fourcc = cv2.VideoWriter_fourcc(*'XVID')
|
||||
# # out = cv2.VideoWriter(fileName, fourcc, 10.0, (512, 612))
|
||||
|
||||
|
||||
def get_best_valid_bits(pixel_format):
|
||||
valid_bits = DxValidBit.BIT0_7
|
||||
if pixel_format in (GxPixelFormatEntry.MONO8, GxPixelFormatEntry.BAYER_GR8, GxPixelFormatEntry.BAYER_RG8, GxPixelFormatEntry.BAYER_GB8, GxPixelFormatEntry.BAYER_BG8
|
||||
, GxPixelFormatEntry.RGB8, GxPixelFormatEntry.BGR8, GxPixelFormatEntry.R8, GxPixelFormatEntry.B8, GxPixelFormatEntry.G8):
|
||||
valid_bits = DxValidBit.BIT0_7
|
||||
elif pixel_format in (GxPixelFormatEntry.MONO10, GxPixelFormatEntry.MONO10_PACKED, GxPixelFormatEntry.BAYER_GR10,
|
||||
GxPixelFormatEntry.BAYER_RG10, GxPixelFormatEntry.BAYER_GB10, GxPixelFormatEntry.BAYER_BG10):
|
||||
valid_bits = DxValidBit.BIT2_9
|
||||
elif pixel_format in (GxPixelFormatEntry.MONO12, GxPixelFormatEntry.MONO12_PACKED, GxPixelFormatEntry.BAYER_GR12,
|
||||
GxPixelFormatEntry.BAYER_RG12, GxPixelFormatEntry.BAYER_GB12, GxPixelFormatEntry.BAYER_BG12):
|
||||
valid_bits = DxValidBit.BIT4_11
|
||||
elif pixel_format in (GxPixelFormatEntry.MONO14):
|
||||
valid_bits = DxValidBit.BIT6_13
|
||||
elif pixel_format in (GxPixelFormatEntry.MONO16):
|
||||
valid_bits = DxValidBit.BIT8_15
|
||||
return valid_bits
|
||||
|
||||
def convert_to_RGB(raw_image):
|
||||
image_convert.set_dest_format(GxPixelFormatEntry.RGB8)
|
||||
valid_bits = get_best_valid_bits(raw_image.get_pixel_format())
|
||||
image_convert.set_valid_bits(valid_bits)
|
||||
|
||||
# create out put image buffer
|
||||
buffer_out_size = image_convert.get_buffer_size_for_conversion(raw_image)
|
||||
output_image_array = (c_ubyte * buffer_out_size)()
|
||||
output_image = addressof(output_image_array)
|
||||
|
||||
#convert to rgb
|
||||
image_convert.convert(raw_image, output_image, buffer_out_size, False)
|
||||
if output_image is None:
|
||||
print('Failed to convert RawImage to RGBImage')
|
||||
return
|
||||
|
||||
return output_image_array, buffer_out_size
|
||||
|
||||
|
||||
# def main():
|
||||
|
||||
def getParam():
|
||||
|
||||
global QRCODE
|
||||
t1 = datetime.now()
|
||||
|
||||
# print the demo information
|
||||
print("")
|
||||
print("-------------------------------------------------------------")
|
||||
print("Sample to show how to acquire color image continuously and show acquired image.")
|
||||
print("-------------------------------------------------------------")
|
||||
print("")
|
||||
print("Initializing......")
|
||||
print("")
|
||||
|
||||
# create a device manager
|
||||
device_manager = gx.DeviceManager()
|
||||
dev_num, dev_info_list = device_manager.update_all_device_list()
|
||||
if dev_num == 0:
|
||||
print("Number of enumerated devices is 0")
|
||||
return
|
||||
|
||||
# open the first device
|
||||
cam = device_manager.open_device_by_index(1)
|
||||
remote_device_feature = cam.get_remote_device_feature_control()
|
||||
|
||||
# get image convert obj
|
||||
global image_convert
|
||||
image_convert = device_manager.create_image_format_convert()
|
||||
|
||||
# get image improvement obj
|
||||
global image_process, image_process_config
|
||||
image_process = device_manager.create_image_process()
|
||||
image_process_config = cam.create_image_process_config()
|
||||
image_process_config.enable_color_correction(False)
|
||||
|
||||
# exit when the camera is a mono camera
|
||||
pixel_format_value, pixel_format_str = remote_device_feature.get_enum_feature("PixelFormat").get()
|
||||
if Utility.is_gray(pixel_format_value):
|
||||
print("This sample does not support mono camera.")
|
||||
cam.close_device()
|
||||
return
|
||||
|
||||
# set continuous acquisition
|
||||
trigger_mode_feature = remote_device_feature.get_enum_feature("TriggerMode")
|
||||
trigger_mode_feature.set("Off")
|
||||
|
||||
# get param of improving image quality
|
||||
if remote_device_feature.is_readable("GammaParam"):
|
||||
gamma_value = remote_device_feature.get_float_feature("GammaParam").get()
|
||||
image_process_config.set_gamma_param(gamma_value)
|
||||
else:
|
||||
image_process_config.set_gamma_param(1)
|
||||
if remote_device_feature.is_readable("ContrastParam"):
|
||||
contrast_value = remote_device_feature.get_int_feature("ContrastParam").get()
|
||||
image_process_config.set_contrast_param(contrast_value)
|
||||
else:
|
||||
image_process_config.set_contrast_param(0)
|
||||
|
||||
# start data acquisition
|
||||
cam.stream_on()
|
||||
|
||||
t2 = datetime.now()
|
||||
|
||||
itemList = []
|
||||
fileBase = "camdata/{}".format(datetime.now().strftime("%Y_%m_%d_%H_%M_%S"))
|
||||
# acquisition image: num is the image number
|
||||
num = 25
|
||||
for i in range(num):
|
||||
t3 = datetime.now()
|
||||
# while True:
|
||||
|
||||
# #HoughLinesP:
|
||||
# threshold = cv2.getTrackbarPos("threshold", "Trackbars")
|
||||
# minLineLength = cv2.getTrackbarPos("minLineLength", "Trackbars")
|
||||
# maxLineGap = cv2.getTrackbarPos("maxLineGap", "Trackbars")
|
||||
|
||||
# #Canny:
|
||||
# threshold1 = cv2.getTrackbarPos("threshold1", "Trackbars")
|
||||
# threshold2 = cv2.getTrackbarPos("threshold2", "Trackbars")
|
||||
# # apertureSize = cv2.getTrackbarPos("apertureSize", "Trackbars")
|
||||
|
||||
# #Hough Circle Transform:
|
||||
# realRadius = cv2.getTrackbarPos("radius", "CircleTrackbars")
|
||||
# blur = cv2.getTrackbarPos("blur", "CircleTrackbars")
|
||||
# param_1 = cv2.getTrackbarPos("param_1", "CircleTrackbars")
|
||||
# param_2 = cv2.getTrackbarPos("param_2", "CircleTrackbars")
|
||||
# min_radius = cv2.getTrackbarPos("min_radius", "CircleTrackbars")
|
||||
# max_radius = cv2.getTrackbarPos("max_radius", "CircleTrackbars")
|
||||
##########
|
||||
# #can not be negative
|
||||
# threshold = threshold if threshold >= 0 else 0
|
||||
# minLineLength = minLineLength if minLineLength >= 0 else 0
|
||||
# maxLineGap = maxLineGap if maxLineGap >= 0 else 0
|
||||
# threshold1 = threshold1 if threshold1 >= 0 else 0
|
||||
# threshold2 = threshold2 if threshold2 >= 0 else 0
|
||||
|
||||
# realRadius = realRadius if realRadius > 0 else 10
|
||||
# blur = blur if blur > 0 else 5
|
||||
|
||||
# if 0 == blur % 2:
|
||||
# blur = blur + 1
|
||||
|
||||
# param_1 = param_1 if param_1 >= 0 else 333
|
||||
# param_2 = param_2 if param_2 >= 0 else 43
|
||||
# min_radius = min_radius if min_radius >= 0 else 0
|
||||
# max_radius = max_radius if max_radius >= 0 else 255
|
||||
##########
|
||||
|
||||
realRadius = 10
|
||||
blur = 5
|
||||
|
||||
# param_1 = 300
|
||||
# param_1 = 250
|
||||
|
||||
# param_1 = 210
|
||||
# param_2 = 36
|
||||
|
||||
# param_1 = 200
|
||||
# param_2 = 28
|
||||
|
||||
# param_1 = 190
|
||||
param_1 = 120
|
||||
param_2 = 28
|
||||
|
||||
min_radius = 50
|
||||
max_radius = 0
|
||||
|
||||
# param_1 = 333
|
||||
# param_2 = 29
|
||||
|
||||
# param_1 = 180
|
||||
# param_2 = 23
|
||||
|
||||
# param_1 = 170
|
||||
# param_2 = 12
|
||||
|
||||
# min_radius = 20
|
||||
# max_radius = 255
|
||||
|
||||
# get raw image
|
||||
raw_image = cam.data_stream[0].get_image()
|
||||
if raw_image is None:
|
||||
print("Getting image failed.")
|
||||
continue
|
||||
|
||||
# get RGB image from raw image
|
||||
image_buf = None
|
||||
if raw_image.get_pixel_format() != GxPixelFormatEntry.RGB8:
|
||||
rgb_image_array, rgb_image_buffer_length = convert_to_RGB(raw_image)
|
||||
if rgb_image_array is None:
|
||||
return
|
||||
# create numpy array with data from rgb image
|
||||
numpy_image = numpy.frombuffer(rgb_image_array, dtype=numpy.ubyte, count=rgb_image_buffer_length). \
|
||||
reshape(raw_image.frame_data.height, raw_image.frame_data.width, 3)
|
||||
image_buf = addressof(rgb_image_array)
|
||||
else:
|
||||
numpy_image = raw_image.get_numpy_array()
|
||||
image_buf = raw_image.frame_data.image_buf
|
||||
|
||||
# 图像质量提升
|
||||
rgb_image = GxImageInfo()
|
||||
rgb_image.image_width = raw_image.frame_data.width
|
||||
rgb_image.image_height = raw_image.frame_data.height
|
||||
rgb_image.image_buf = image_buf
|
||||
rgb_image.image_pixel_format = GxPixelFormatEntry.RGB8
|
||||
|
||||
# improve image quality
|
||||
image_process.image_improvement(rgb_image, image_buf, image_process_config)
|
||||
|
||||
if numpy_image is None:
|
||||
continue
|
||||
|
||||
# # show acquired image
|
||||
# img = Image.fromarray(numpy_image, 'RGB')
|
||||
# img.show()
|
||||
|
||||
# # print height, width, and frame ID of the acquisition image
|
||||
# print("Frame ID: %d Height: %d Width: %d"
|
||||
# % (raw_image.get_frame_id(), raw_image.get_height(), raw_image.get_width()))
|
||||
|
||||
|
||||
src = cv.resize(numpy_image, (0,0), fx=0.25, fy=0.25)
|
||||
|
||||
fileNameImage = "qrcode_{}.jpg".format(fileBase)
|
||||
cv2.imwrite(fileNameImage, src)
|
||||
|
||||
decoded_list = decode(src)
|
||||
|
||||
if len(decoded_list) > 0:
|
||||
print("decoded_list: ", decoded_list)
|
||||
urlB = decoded_list[0].data
|
||||
QRCODE = urlB.decode()
|
||||
|
||||
h, w, _ = src.shape
|
||||
# print("h {}, w: {}", h, w)
|
||||
|
||||
halfRADIUS = math.floor(MASK_RADIUS/2)
|
||||
|
||||
halfHigh = math.floor(h / 2)
|
||||
halfWidth = math.floor(w / 2)
|
||||
|
||||
# print("halfRADIUS: ", halfRADIUS )
|
||||
# src = src[ halfHigh-halfRADIUS: halfHigh+halfRADIUS, halfWidth-halfRADIUS: halfWidth+halfRADIUS]
|
||||
h, w, _ = src.shape
|
||||
|
||||
# fileNameImage = "{}.original.jpg".format(fileBase)
|
||||
# cv2.imwrite(fileNameImage, src)
|
||||
|
||||
# out.write(src)
|
||||
|
||||
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
|
||||
# # gray = cv.medianBlur(gray, 5)
|
||||
|
||||
# # dst = cv2.Canny(src, threshold1, threshold2, None, 3)
|
||||
# dst = cv2.Canny(gray, threshold1, threshold2, None, 3)
|
||||
# cdstP = cv2.cvtColor(dst, cv2.COLOR_GRAY2BGR)
|
||||
|
||||
# # linesP = cv2.HoughLinesP(dst, 1, np.pi / 180, 50, None, 50, 10)
|
||||
# linesP = cv2.HoughLinesP(dst, 1, np.pi / 180, threshold, None, minLineLength, maxLineGap)
|
||||
|
||||
# if linesP is not None:
|
||||
# for i in range(0, len(linesP)):
|
||||
# l = linesP[i][0]
|
||||
# cv2.line(cdstP, (l[0], l[1]), (l[2], l[3]), (0,0,255), 3, cv2.LINE_AA)
|
||||
|
||||
# #draw circles
|
||||
# cv2.circle(cdstP, (l[0], l[1]), 10, (0,255,0), -1)
|
||||
# cv2.circle(cdstP, (l[2], l[3]), 10, (0,255,0), -1)
|
||||
|
||||
|
||||
gray = cv2.medianBlur(gray, blur)
|
||||
# cv2.imshow("gray", gray)
|
||||
|
||||
rows = gray.shape[0]
|
||||
|
||||
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, rows / 8,
|
||||
param1=param_1, param2=param_2,
|
||||
minRadius=min_radius, maxRadius=max_radius)
|
||||
|
||||
if circles is not None:
|
||||
circles = np.uint16(np.around(circles))
|
||||
for i in circles[0, :]:
|
||||
center = (i[0], i[1])
|
||||
# circle center
|
||||
# # cv2.circle(src, center, 1, (0, 100, 100), 3)
|
||||
# cv2.circle(src, center, 1, (60, 100, 100), 3)
|
||||
# circle outline
|
||||
radius = i[2]
|
||||
# #cv2.circle(src, center, radius, (255, 0, 255), 3)
|
||||
# cv2.circle(src, center, radius, (190, 90, 190), 3)
|
||||
|
||||
dx = center[0] - math.floor(w/2)
|
||||
dy = center[1] - math.floor(h/2)
|
||||
|
||||
if len(itemList) > 0:
|
||||
|
||||
addNew = True
|
||||
for item in itemList:
|
||||
|
||||
# print("abs(int(center[0]) - item[0]) = {}, {}, {}".format(abs(int(center[0]) - item[0]), int(center[0]), item[0]))
|
||||
# print("abs(int(center[1]) - item[1]) = {}, {}, {}".format(abs(int(center[1]) - item[1]), int(center[1]), item[1]))
|
||||
# print("abs(int(radius) - item[2]) = {}, {}, {}".format(abs(int(radius) - item[2]), int(radius), item[2]))
|
||||
|
||||
if abs(int(center[0]) - item[0]) < DX_RANGE \
|
||||
and abs(int(center[1]) - item[1]) < DY_RANGE \
|
||||
and abs(int(radius) - item[2]) < RADIUS_RANGE:
|
||||
# print("Appen Existing, dx: {}, dy: {}, radius: {}".format(dx, dy, radius ))
|
||||
item[5] = item[5] + 1
|
||||
addNew = False
|
||||
|
||||
if addNew:
|
||||
# print("Add New, dx: {}, dy: {}, radius: {}".format(dx, dy, radius ))
|
||||
itemList.append([int(center[0]), int(center[1]), int(radius), int(dx), int(dy), 1])
|
||||
else:
|
||||
# print("Add New, dx: {}, dy: {}, radius: {}".format(dx, dy, radius ))
|
||||
itemList.append([int(center[0]), int(center[1]), int(radius), int(dx), int(dy), 1])
|
||||
|
||||
ratio = realRadius / radius
|
||||
ddx = math.floor(dx * ratio)
|
||||
ddy = math.floor(dy * ratio)
|
||||
dratio = math.floor(radius * ratio)
|
||||
# print("Real: ddx: {}, ddy: {}, radius: {}".format(ddx, ddy, dratio))
|
||||
|
||||
|
||||
cv2.line(src, (math.floor(w/2), 0), (math.floor(w/2), h), (255, 0,0), 1, cv2.LINE_AA)
|
||||
cv2.line(src, (0, math.floor(h/2)), (w, math.floor(h/2)), (255, 0,0), 1, cv2.LINE_AA)
|
||||
|
||||
cv2.circle(src, (math.floor(w/2), math.floor(h/2)), 5, (255, 100, 100), 3)
|
||||
|
||||
# cv2.imshow("Source", src)
|
||||
# # cv2.imshow("Detected Lines (in red) - Probabilistic Line Transform", cdstP)
|
||||
|
||||
t4 = datetime.now()
|
||||
|
||||
# key = cv2.waitKey(1)
|
||||
# if key == 27:
|
||||
# break
|
||||
|
||||
# out.release()
|
||||
# stop data acquisition
|
||||
cam.stream_off()
|
||||
# close device
|
||||
cam.close_device()
|
||||
|
||||
t5 = datetime.now()
|
||||
|
||||
item = None
|
||||
if len(itemList) > 0:
|
||||
# print("itemList: ", itemList)
|
||||
|
||||
itemList.sort(key = lambda item: item[5], reverse=True )
|
||||
item = itemList[0]
|
||||
cv2.circle(src, (item[0], item[1]), 1, (60, 100, 100), 3)
|
||||
cv2.circle(src, (item[0], item[1]), item[2], (190, 90, 190), 3)
|
||||
|
||||
print("Optimal dx: {}, dy: {}, radius: {}".format(item[3], item[4], item[2] ))
|
||||
|
||||
fileNameImage = "{}.jpg".format(fileBase)
|
||||
cv2.imwrite(fileNameImage, src)
|
||||
|
||||
fileNameJson = "{}.json".format(fileBase)
|
||||
|
||||
with open(fileNameJson, "w") as fp:
|
||||
json.dump(itemList, fp)
|
||||
|
||||
t6 = datetime.now()
|
||||
|
||||
# print("start time t2 - t1: {}", t2-t1)
|
||||
# print("one round time t4 - t3: {}", t4-t3)
|
||||
# print("15 times t5 - t2: {}", t5-t2)
|
||||
# print("write image t6 - t5: {}", t6-t5)
|
||||
# print("Total t6 - t1: {}", t6-t1)
|
||||
|
||||
# item = [x, y, radius, dx, dy, frequency]
|
||||
if item and item[3] < 300 and item[4] < 300 and item[5] > 3:
|
||||
return item, QRCODE
|
||||
elif item:
|
||||
print("Abnorm Value, {}, {}".format(item[3], item[4]))
|
||||
return None, QRCODE
|
||||
else:
|
||||
return None, QRCODE
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# main()
|
@ -0,0 +1,324 @@
|
||||
# version:1.1.2312.9221
|
||||
from . import gxipy as gx
|
||||
from PIL import Image
|
||||
from ctypes import *
|
||||
from .gxipy.gxidef import *
|
||||
import numpy
|
||||
from .gxipy.ImageFormatConvert import *
|
||||
from datetime import datetime
|
||||
from helper.logger import logger
|
||||
import cv2
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
import math
|
||||
import json
|
||||
|
||||
import pyzbar
|
||||
|
||||
from PIL import Image
|
||||
from pyzbar.pyzbar import decode, ZBarSymbol
|
||||
|
||||
|
||||
DX_RANGE = 5
|
||||
DY_RANGE = 5
|
||||
RADIUS_RANGE = 10
|
||||
|
||||
# MASK_RADIUS = 400
|
||||
MASK_RADIUS = 500
|
||||
|
||||
QRCODE = None
|
||||
|
||||
def nothing(x):
|
||||
# any operation
|
||||
pass
|
||||
|
||||
def get_best_valid_bits(pixel_format):
|
||||
valid_bits = DxValidBit.BIT0_7
|
||||
if pixel_format in (GxPixelFormatEntry.MONO8, GxPixelFormatEntry.BAYER_GR8, GxPixelFormatEntry.BAYER_RG8, GxPixelFormatEntry.BAYER_GB8, GxPixelFormatEntry.BAYER_BG8
|
||||
, GxPixelFormatEntry.RGB8, GxPixelFormatEntry.BGR8, GxPixelFormatEntry.R8, GxPixelFormatEntry.B8, GxPixelFormatEntry.G8):
|
||||
valid_bits = DxValidBit.BIT0_7
|
||||
elif pixel_format in (GxPixelFormatEntry.MONO10, GxPixelFormatEntry.MONO10_PACKED, GxPixelFormatEntry.BAYER_GR10,
|
||||
GxPixelFormatEntry.BAYER_RG10, GxPixelFormatEntry.BAYER_GB10, GxPixelFormatEntry.BAYER_BG10):
|
||||
valid_bits = DxValidBit.BIT2_9
|
||||
elif pixel_format in (GxPixelFormatEntry.MONO12, GxPixelFormatEntry.MONO12_PACKED, GxPixelFormatEntry.BAYER_GR12,
|
||||
GxPixelFormatEntry.BAYER_RG12, GxPixelFormatEntry.BAYER_GB12, GxPixelFormatEntry.BAYER_BG12):
|
||||
valid_bits = DxValidBit.BIT4_11
|
||||
elif pixel_format in (GxPixelFormatEntry.MONO14):
|
||||
valid_bits = DxValidBit.BIT6_13
|
||||
elif pixel_format in (GxPixelFormatEntry.MONO16):
|
||||
valid_bits = DxValidBit.BIT8_15
|
||||
return valid_bits
|
||||
|
||||
def convert_to_RGB(raw_image):
|
||||
image_convert.set_dest_format(GxPixelFormatEntry.RGB8)
|
||||
valid_bits = get_best_valid_bits(raw_image.get_pixel_format())
|
||||
image_convert.set_valid_bits(valid_bits)
|
||||
|
||||
# create out put image buffer
|
||||
buffer_out_size = image_convert.get_buffer_size_for_conversion(raw_image)
|
||||
output_image_array = (c_ubyte * buffer_out_size)()
|
||||
output_image = addressof(output_image_array)
|
||||
|
||||
#convert to rgb
|
||||
image_convert.convert(raw_image, output_image, buffer_out_size, False)
|
||||
if output_image is None:
|
||||
print('Failed to convert RawImage to RGBImage')
|
||||
return
|
||||
|
||||
return output_image_array, buffer_out_size
|
||||
|
||||
|
||||
# def main():
|
||||
|
||||
def getParam():
|
||||
|
||||
global QRCODE
|
||||
t1 = datetime.now()
|
||||
|
||||
# print the demo information
|
||||
print("")
|
||||
print("-------------------------------------------------------------")
|
||||
print("Sample to show how to acquire color image continuously and show acquired image.")
|
||||
print("-------------------------------------------------------------")
|
||||
print("")
|
||||
print("Initializing......")
|
||||
print("")
|
||||
|
||||
# create a device manager
|
||||
device_manager = gx.DeviceManager()
|
||||
dev_num, dev_info_list = device_manager.update_all_device_list()
|
||||
if dev_num == 0:
|
||||
print("Number of enumerated devices is 0")
|
||||
return
|
||||
|
||||
try:
|
||||
# open the first device
|
||||
cam = device_manager.open_device_by_index(1)
|
||||
except Exception as e:
|
||||
print(F"getParam() Exception: {e}")
|
||||
if cam:
|
||||
# stop data acquisition
|
||||
cam.stream_off()
|
||||
# close device
|
||||
cam.close_device()
|
||||
|
||||
return None, None
|
||||
|
||||
try:
|
||||
|
||||
remote_device_feature = cam.get_remote_device_feature_control()
|
||||
|
||||
# get image convert obj
|
||||
global image_convert
|
||||
image_convert = device_manager.create_image_format_convert()
|
||||
|
||||
# get image improvement obj
|
||||
global image_process, image_process_config
|
||||
image_process = device_manager.create_image_process()
|
||||
image_process_config = cam.create_image_process_config()
|
||||
image_process_config.enable_color_correction(False)
|
||||
|
||||
# exit when the camera is a mono camera
|
||||
pixel_format_value, pixel_format_str = remote_device_feature.get_enum_feature("PixelFormat").get()
|
||||
if Utility.is_gray(pixel_format_value):
|
||||
print("This sample does not support mono camera.")
|
||||
cam.close_device()
|
||||
return
|
||||
|
||||
# set continuous acquisition
|
||||
trigger_mode_feature = remote_device_feature.get_enum_feature("TriggerMode")
|
||||
trigger_mode_feature.set("Off")
|
||||
|
||||
# get param of improving image quality
|
||||
if remote_device_feature.is_readable("GammaParam"):
|
||||
gamma_value = remote_device_feature.get_float_feature("GammaParam").get()
|
||||
image_process_config.set_gamma_param(gamma_value)
|
||||
else:
|
||||
image_process_config.set_gamma_param(1)
|
||||
if remote_device_feature.is_readable("ContrastParam"):
|
||||
contrast_value = remote_device_feature.get_int_feature("ContrastParam").get()
|
||||
image_process_config.set_contrast_param(contrast_value)
|
||||
else:
|
||||
image_process_config.set_contrast_param(0)
|
||||
|
||||
# start data acquisition
|
||||
cam.stream_on()
|
||||
|
||||
t2 = datetime.now()
|
||||
|
||||
itemList = []
|
||||
fileBase = "camdata/{}".format(datetime.now().strftime("%Y_%m_%d_%H_%M_%S"))
|
||||
# acquisition image: num is the image number
|
||||
num = 25
|
||||
for i in range(num):
|
||||
t3 = datetime.now()
|
||||
# while True:
|
||||
|
||||
realRadius = 10
|
||||
blur = 5
|
||||
|
||||
param_1 = 120
|
||||
param_2 = 28
|
||||
|
||||
min_radius = 50
|
||||
max_radius = 0
|
||||
|
||||
# get raw image
|
||||
raw_image = cam.data_stream[0].get_image()
|
||||
if raw_image is None:
|
||||
print("Getting image failed.")
|
||||
continue
|
||||
|
||||
# get RGB image from raw image
|
||||
image_buf = None
|
||||
if raw_image.get_pixel_format() != GxPixelFormatEntry.RGB8:
|
||||
rgb_image_array, rgb_image_buffer_length = convert_to_RGB(raw_image)
|
||||
if rgb_image_array is None:
|
||||
return
|
||||
# create numpy array with data from rgb image
|
||||
numpy_image = numpy.frombuffer(rgb_image_array, dtype=numpy.ubyte, count=rgb_image_buffer_length). \
|
||||
reshape(raw_image.frame_data.height, raw_image.frame_data.width, 3)
|
||||
image_buf = addressof(rgb_image_array)
|
||||
else:
|
||||
numpy_image = raw_image.get_numpy_array()
|
||||
image_buf = raw_image.frame_data.image_buf
|
||||
|
||||
# 图像质量提升
|
||||
rgb_image = GxImageInfo()
|
||||
rgb_image.image_width = raw_image.frame_data.width
|
||||
rgb_image.image_height = raw_image.frame_data.height
|
||||
rgb_image.image_buf = image_buf
|
||||
rgb_image.image_pixel_format = GxPixelFormatEntry.RGB8
|
||||
|
||||
# improve image quality
|
||||
image_process.image_improvement(rgb_image, image_buf, image_process_config)
|
||||
|
||||
if numpy_image is None:
|
||||
continue
|
||||
|
||||
src = cv.resize(numpy_image, (0,0), fx=0.25, fy=0.25)
|
||||
|
||||
fileNameImage = "qrcode_{}.jpg".format(fileBase)
|
||||
cv2.imwrite(fileNameImage, src)
|
||||
|
||||
decoded_list = decode(src)
|
||||
|
||||
if len(decoded_list) > 0:
|
||||
print("decoded_list: ", decoded_list)
|
||||
urlB = decoded_list[0].data
|
||||
QRCODE = urlB.decode()
|
||||
|
||||
h, w, _ = src.shape
|
||||
|
||||
# fileNameImage = "{}.original.jpg".format(fileBase)
|
||||
# cv2.imwrite(fileNameImage, src)
|
||||
|
||||
# out.write(src)
|
||||
|
||||
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
|
||||
|
||||
gray = cv2.medianBlur(gray, blur)
|
||||
# cv2.imshow("gray", gray)
|
||||
|
||||
rows = gray.shape[0]
|
||||
|
||||
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, rows / 8,
|
||||
param1=param_1, param2=param_2,
|
||||
minRadius=min_radius, maxRadius=max_radius)
|
||||
|
||||
if circles is not None:
|
||||
circles = np.uint16(np.around(circles))
|
||||
for i in circles[0, :]:
|
||||
center = (i[0], i[1])
|
||||
# circle center
|
||||
# # cv2.circle(src, center, 1, (0, 100, 100), 3)
|
||||
# cv2.circle(src, center, 1, (60, 100, 100), 3)
|
||||
# circle outline
|
||||
radius = i[2]
|
||||
# #cv2.circle(src, center, radius, (255, 0, 255), 3)
|
||||
# cv2.circle(src, center, radius, (190, 90, 190), 3)
|
||||
|
||||
dx = center[0] - math.floor(w/2)
|
||||
dy = center[1] - math.floor(h/2)
|
||||
|
||||
if len(itemList) > 0:
|
||||
|
||||
addNew = True
|
||||
for item in itemList:
|
||||
|
||||
if abs(int(center[0]) - item[0]) < DX_RANGE \
|
||||
and abs(int(center[1]) - item[1]) < DY_RANGE \
|
||||
and abs(int(radius) - item[2]) < RADIUS_RANGE:
|
||||
# print("Appen Existing, dx: {}, dy: {}, radius: {}".format(dx, dy, radius ))
|
||||
item[5] = item[5] + 1
|
||||
addNew = False
|
||||
|
||||
if addNew:
|
||||
# print("Add New, dx: {}, dy: {}, radius: {}".format(dx, dy, radius ))
|
||||
itemList.append([int(center[0]), int(center[1]), int(radius), int(dx), int(dy), 1])
|
||||
else:
|
||||
# print("Add New, dx: {}, dy: {}, radius: {}".format(dx, dy, radius ))
|
||||
itemList.append([int(center[0]), int(center[1]), int(radius), int(dx), int(dy), 1])
|
||||
|
||||
ratio = realRadius / radius
|
||||
ddx = math.floor(dx * ratio)
|
||||
ddy = math.floor(dy * ratio)
|
||||
dratio = math.floor(radius * ratio)
|
||||
# print("Real: ddx: {}, ddy: {}, radius: {}".format(ddx, ddy, dratio))
|
||||
|
||||
|
||||
cv2.line(src, (math.floor(w/2), 0), (math.floor(w/2), h), (255, 0,0), 1, cv2.LINE_AA)
|
||||
cv2.line(src, (0, math.floor(h/2)), (w, math.floor(h/2)), (255, 0,0), 1, cv2.LINE_AA)
|
||||
|
||||
cv2.circle(src, (math.floor(w/2), math.floor(h/2)), 5, (255, 100, 100), 3)
|
||||
|
||||
# cv2.imshow("Source", src)
|
||||
# # cv2.imshow("Detected Lines (in red) - Probabilistic Line Transform", cdstP)
|
||||
|
||||
t4 = datetime.now()
|
||||
|
||||
# key = cv2.waitKey(1)
|
||||
# if key == 27:
|
||||
# break
|
||||
|
||||
except Exception as e:
|
||||
logger.info(F"getParam Exception: {e}")
|
||||
|
||||
# out.release()
|
||||
# stop data acquisition
|
||||
cam.stream_off()
|
||||
# close device
|
||||
cam.close_device()
|
||||
|
||||
t5 = datetime.now()
|
||||
|
||||
item = None
|
||||
if len(itemList) > 0:
|
||||
# print("itemList: ", itemList)
|
||||
|
||||
itemList.sort(key = lambda item: item[5], reverse=True )
|
||||
item = itemList[0]
|
||||
cv2.circle(src, (item[0], item[1]), 1, (60, 100, 100), 3)
|
||||
cv2.circle(src, (item[0], item[1]), item[2], (190, 90, 190), 3)
|
||||
|
||||
print("Optimal dx: {}, dy: {}, radius: {}".format(item[3], item[4], item[2] ))
|
||||
|
||||
fileNameImage = "{}.jpg".format(fileBase)
|
||||
cv2.imwrite(fileNameImage, src)
|
||||
|
||||
fileNameJson = "{}.json".format(fileBase)
|
||||
|
||||
with open(fileNameJson, "w") as fp:
|
||||
json.dump(itemList, fp)
|
||||
|
||||
t6 = datetime.now()
|
||||
|
||||
# item = [x, y, radius, dx, dy, frequency]
|
||||
if item and item[3] < 300 and item[4] < 300 and item[5] > 3:
|
||||
return item, QRCODE
|
||||
elif item:
|
||||
print("Abnorm Value, {}, {}".format(item[3], item[4]))
|
||||
return None, QRCODE
|
||||
else:
|
||||
return None, QRCODE
|
||||
|
@ -0,0 +1,256 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .gxiapi import *
|
||||
from .StatusProcessor import *
|
||||
from .Interface import *
|
||||
from .Feature import *
|
||||
from .Exception import *
|
||||
from .ImageProc import *
|
||||
import ctypes
|
||||
import types
|
||||
|
||||
class DataStream:
|
||||
def __init__(self, dev_handle, stream_handle):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param dev_handle: Device handle
|
||||
:param stream_handle: Device Stream handle
|
||||
"""
|
||||
self.__dev_handle = dev_handle
|
||||
|
||||
self.__c_capture_callback = CAP_CALL(self.__on_capture_callback)
|
||||
self.__py_capture_callback = None
|
||||
|
||||
self.StreamAnnouncedBufferCount = IntFeature(self.__dev_handle, GxFeatureID.INT_ANNOUNCED_BUFFER_COUNT)
|
||||
self.StreamDeliveredFrameCount = IntFeature(self.__dev_handle, GxFeatureID.INT_DELIVERED_FRAME_COUNT)
|
||||
self.StreamLostFrameCount = IntFeature(self.__dev_handle, GxFeatureID.INT_LOST_FRAME_COUNT)
|
||||
self.StreamIncompleteFrameCount = IntFeature(self.__dev_handle, GxFeatureID.INT_INCOMPLETE_FRAME_COUNT)
|
||||
self.StreamDeliveredPacketCount = IntFeature(self.__dev_handle, GxFeatureID.INT_DELIVERED_PACKET_COUNT)
|
||||
self.StreamBufferHandlingMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_STREAM_BUFFER_HANDLING_MODE)
|
||||
self.payload_size = 0
|
||||
self.acquisition_flag = False
|
||||
self.__data_stream_handle = stream_handle
|
||||
self.__stream_feature_control = FeatureControl(stream_handle)
|
||||
self.__frame_buf_map = {}
|
||||
|
||||
def get_feature_control(self):
|
||||
"""
|
||||
:brief Get device stream feature control object
|
||||
:return: Device stream feature control object
|
||||
"""
|
||||
return self.__stream_feature_control
|
||||
|
||||
def get_payload_size(self):
|
||||
"""
|
||||
:brief Get device stream payload size
|
||||
:return: Payload size
|
||||
"""
|
||||
status, stream_payload_size = gx_get_payload_size(self.__data_stream_handle)
|
||||
StatusProcessor.process(status, 'DataStreamHandle', 'get_payload_size')
|
||||
return stream_payload_size
|
||||
|
||||
def get_image(self, timeout=1000):
|
||||
"""
|
||||
:brief Get an image, get successfully create image class object
|
||||
:param timeout: Acquisition timeout, range:[0, 0xFFFFFFFF]
|
||||
:return: image object
|
||||
"""
|
||||
if not isinstance(timeout, INT_TYPE):
|
||||
raise ParameterTypeError("DataStream.get_image: "
|
||||
"Expected timeout type is int, not %s" % type(timeout))
|
||||
|
||||
if (timeout < 0) or (timeout > UNSIGNED_INT_MAX):
|
||||
print("DataStream.get_image: "
|
||||
"timeout out of bounds, minimum=0, maximum=%s"
|
||||
% hex(UNSIGNED_INT_MAX).__str__())
|
||||
return None
|
||||
|
||||
if self.acquisition_flag is False:
|
||||
print("DataStream.get_image: Current data steam don't start acquisition")
|
||||
return None
|
||||
|
||||
frame_data = GxFrameData()
|
||||
frame_data.image_size = self.payload_size
|
||||
frame_data.image_buf = None
|
||||
image = RawImage(frame_data)
|
||||
|
||||
status = gx_get_image(self.__dev_handle, image.frame_data, timeout)
|
||||
if status == GxStatusList.SUCCESS:
|
||||
return image
|
||||
elif status == GxStatusList.TIMEOUT:
|
||||
return None
|
||||
else:
|
||||
StatusProcessor.process(status, 'DataStream', 'get_image')
|
||||
return None
|
||||
|
||||
def dq_buf(self, timeout=1000):
|
||||
if not isinstance(timeout, INT_TYPE):
|
||||
raise ParameterTypeError("DataStream.dq_buf: "
|
||||
"Expected timeout type is int, not %s" % type(timeout))
|
||||
|
||||
if (timeout < 0) or (timeout > UNSIGNED_INT_MAX):
|
||||
print("DataStream.get_image: "
|
||||
"timeout out of bounds, minimum=0, maximum=%s"
|
||||
% hex(UNSIGNED_INT_MAX).__str__())
|
||||
return None
|
||||
|
||||
if self.__py_capture_callback != None:
|
||||
raise InvalidCall("Can't call DQBuf after register capture callback")
|
||||
|
||||
if self.acquisition_flag is False:
|
||||
print("DataStream.get_image: Current data steam don't start acquisition")
|
||||
return None
|
||||
|
||||
ptr_frame_buffer = ctypes.POINTER(GxFrameBuffer)()
|
||||
status = gx_dq_buf(self.__dev_handle, ctypes.byref(ptr_frame_buffer), timeout)
|
||||
if status == GxStatusList.SUCCESS:
|
||||
frame_buffer = ptr_frame_buffer.contents
|
||||
self.__frame_buf_map[frame_buffer.buf_id] = ptr_frame_buffer
|
||||
frame_data = GxFrameData()
|
||||
frame_data.status = frame_buffer.status
|
||||
frame_data.image_buf = frame_buffer.image_buf
|
||||
frame_data.width = frame_buffer.width
|
||||
frame_data.height = frame_buffer.height
|
||||
frame_data.pixel_format = frame_buffer.pixel_format
|
||||
frame_data.image_size = frame_buffer.image_size
|
||||
frame_data.frame_id = frame_buffer.frame_id
|
||||
frame_data.timestamp = frame_buffer.timestamp
|
||||
frame_data.buf_id = frame_buffer.buf_id
|
||||
|
||||
image = RawImage(frame_data)
|
||||
return image
|
||||
elif status == GxStatusList.TIMEOUT:
|
||||
return None
|
||||
else:
|
||||
StatusProcessor.process(status, 'DataStream', 'dq_buf')
|
||||
return None
|
||||
|
||||
def q_buf(self, image):
|
||||
if not isinstance(image, RawImage):
|
||||
raise ParameterTypeError("DataStream.q_buf: "
|
||||
"Expected image type is RawImage, not %s" % type(image))
|
||||
|
||||
if self.acquisition_flag is False:
|
||||
print("DataStream.get_image: Current data steam don't start acquisition")
|
||||
return
|
||||
|
||||
if self.__py_capture_callback != None:
|
||||
raise InvalidCall("Can't call DQBuf after register capture callback")
|
||||
|
||||
ptr_frame_buffer = ctypes.POINTER(GxFrameBuffer)()
|
||||
try:
|
||||
ptr_frame_buffer = self.__frame_buf_map[image.frame_data.buf_id]
|
||||
except KeyError:
|
||||
print(f"Key {image.frame_data.buf_id} not found in frame buffer map.")
|
||||
return
|
||||
|
||||
status = gx_q_buf(self.__dev_handle, ptr_frame_buffer)
|
||||
StatusProcessor.process(status, 'DataStream', 'q_buf')
|
||||
self.__frame_buf_map.pop(image.frame_data.buf_id)
|
||||
|
||||
def flush_queue(self):
|
||||
status = gx_flush_queue(self.__dev_handle)
|
||||
StatusProcessor.process(status, 'DataStream', 'flush_queue')
|
||||
|
||||
# old call mode,Not recommended
|
||||
def set_payload_size(self, payload_size):
|
||||
self.payload_size = payload_size
|
||||
|
||||
def set_acquisition_flag(self, flag):
|
||||
self.acquisition_flag = flag
|
||||
|
||||
def set_acquisition_buffer_number(self, buf_num):
|
||||
"""
|
||||
:brief set the number of acquisition buffer
|
||||
:param buf_num: the number of acquisition buffer, range:[1, 0xFFFFFFFF]
|
||||
"""
|
||||
if not isinstance(buf_num, INT_TYPE):
|
||||
raise ParameterTypeError("DataStream.set_acquisition_buffer_number: "
|
||||
"Expected buf_num type is int, not %s" % type(buf_num))
|
||||
|
||||
if (buf_num < 1) or (buf_num > UNSIGNED_LONG_LONG_MAX):
|
||||
print("DataStream.set_acquisition_buffer_number:"
|
||||
"buf_num out of bounds, minimum=1, maximum=%s"
|
||||
% hex(UNSIGNED_LONG_LONG_MAX).__str__())
|
||||
return
|
||||
|
||||
status = gx_set_acquisition_buffer_number(self.__dev_handle, buf_num)
|
||||
StatusProcessor.process(status, 'DataStream', 'set_acquisition_buffer_number')
|
||||
|
||||
def register_capture_callback(self, callback_func):
|
||||
"""
|
||||
:brief Register the capture event callback function.
|
||||
:param callback_func: callback function
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(callback_func, types.FunctionType):
|
||||
raise ParameterTypeError("DataStream.register_capture_callback: "
|
||||
"Expected callback type is function not %s" % type(callback_func))
|
||||
|
||||
status = gx_register_capture_callback(self.__dev_handle, self.__c_capture_callback)
|
||||
StatusProcessor.process(status, 'DataStream', 'register_capture_callback')
|
||||
|
||||
# callback will not recorded when register callback failed.
|
||||
self.__py_capture_callback = callback_func
|
||||
|
||||
def unregister_capture_callback(self):
|
||||
"""
|
||||
:brief Unregister the capture event callback function.
|
||||
:return: none
|
||||
"""
|
||||
status = gx_unregister_capture_callback(self.__dev_handle)
|
||||
StatusProcessor.process(status, 'DataStream', 'unregister_capture_callback')
|
||||
self.__py_capture_callback = None
|
||||
|
||||
def __on_capture_callback(self, capture_data):
|
||||
"""
|
||||
:brief Capture event callback function with capture date.
|
||||
:return: none
|
||||
"""
|
||||
frame_data = GxFrameData()
|
||||
frame_data.image_buf = capture_data.contents.image_buf
|
||||
frame_data.width = capture_data.contents.width
|
||||
frame_data.height = capture_data.contents.height
|
||||
frame_data.pixel_format = capture_data.contents.pixel_format
|
||||
frame_data.image_size = capture_data.contents.image_size
|
||||
frame_data.frame_id = capture_data.contents.frame_id
|
||||
frame_data.timestamp = capture_data.contents.timestamp
|
||||
frame_data.status = capture_data.contents.status
|
||||
# frame_data.buf_id = capture_data.contents.buf_id
|
||||
image = RawImage(frame_data)
|
||||
self.__py_capture_callback(image)
|
||||
|
||||
class U3VDataStream(DataStream):
|
||||
def __init__(self, dev_handle, stream_handle):
|
||||
self.__handle = dev_handle
|
||||
DataStream.__init__(self, self.__handle, stream_handle)
|
||||
self.StreamTransferSize = IntFeature(self.__handle, GxFeatureID.INT_STREAM_TRANSFER_SIZE)
|
||||
self.StreamTransferNumberUrb = IntFeature(self.__handle, GxFeatureID.INT_STREAM_TRANSFER_NUMBER_URB)
|
||||
self.StopAcquisitionMode = EnumFeature(self.__handle, GxFeatureID.ENUM_STOP_ACQUISITION_MODE)
|
||||
|
||||
|
||||
class GEVDataStream(DataStream):
|
||||
def __init__(self, dev_handle, stream_handle):
|
||||
self.__handle = dev_handle
|
||||
DataStream.__init__(self, self.__handle, stream_handle)
|
||||
self.StreamResendPacketCount = IntFeature(self.__handle, GxFeatureID.INT_RESEND_PACKET_COUNT)
|
||||
self.StreamRescuedPacketCount = IntFeature(self.__handle, GxFeatureID.INT_RESCUED_PACKET_COUNT)
|
||||
self.StreamResendCommandCount = IntFeature(self.__handle, GxFeatureID.INT_RESEND_COMMAND_COUNT)
|
||||
self.StreamUnexpectedPacketCount = IntFeature(self.__handle, GxFeatureID.INT_UNEXPECTED_PACKET_COUNT)
|
||||
self.MaxPacketCountInOneBlock = IntFeature(self.__handle, GxFeatureID.INT_MAX_PACKET_COUNT_IN_ONE_BLOCK)
|
||||
self.MaxPacketCountInOneCommand = IntFeature(self.__handle, GxFeatureID.INT_MAX_PACKET_COUNT_IN_ONE_COMMAND)
|
||||
self.ResendTimeout = IntFeature(self.__handle, GxFeatureID.INT_RESEND_TIMEOUT)
|
||||
self.MaxWaitPacketCount = IntFeature(self.__handle, GxFeatureID.INT_MAX_WAIT_PACKET_COUNT)
|
||||
self.ResendMode = EnumFeature(self.__handle, GxFeatureID.ENUM_RESEND_MODE)
|
||||
self.StreamMissingBlockIDCount = IntFeature(self.__handle, GxFeatureID.INT_MISSING_BLOCK_ID_COUNT)
|
||||
self.BlockTimeout = IntFeature(self.__handle, GxFeatureID.INT_BLOCK_TIMEOUT)
|
||||
self.MaxNumQueueBuffer = IntFeature(self.__handle, GxFeatureID.INT_MAX_NUM_QUEUE_BUFFER)
|
||||
self.PacketTimeout = IntFeature(self.__handle, GxFeatureID.INT_PACKET_TIMEOUT)
|
||||
self.SocketBufferSize = IntFeature(self.__handle, GxFeatureID.INT_SOCKET_BUFFER_SIZE)
|
||||
|
@ -0,0 +1,901 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .gxiapi import *
|
||||
from .StatusProcessor import *
|
||||
from .Feature import *
|
||||
from .FeatureControl import *
|
||||
from .ImageProc import *
|
||||
from .ImageProcessConfig import *
|
||||
from .DataStream import *
|
||||
import types
|
||||
|
||||
class Device:
|
||||
"""
|
||||
The Camera class mainly encapsulates some common operations and function attributes,
|
||||
which are the operations and properties usually found in the camera.
|
||||
In addition, this class also encapsulates the common operations of some functions in the C interface,
|
||||
such as SetInt, SetFloat, etc. Can not open to the user, so that when the subsequent addition of features,
|
||||
Python interface does not upgrade, or only the definition of the control code can support new features
|
||||
"""
|
||||
|
||||
def __init__(self, handle, interface_obj):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Device handle
|
||||
"""
|
||||
self.__dev_handle = handle
|
||||
self.data_stream = []
|
||||
self.__interface_obj = interface_obj
|
||||
|
||||
self.__c_offline_callback = OFF_LINE_CALL(self.__on_device_offline_callback)
|
||||
self.__py_offline_callback = None
|
||||
self.__offline_callback_handle = None
|
||||
|
||||
self.__c_feature_callback = FEATURE_CALL(self.__on_device_feature_callback)
|
||||
self.__py_feature_callback = None
|
||||
self.__color_correction_param = 0
|
||||
|
||||
# Function code function is obsolete, please use string to obtain attribute value
|
||||
# ---------------Device Information Section--------------------------
|
||||
self.DeviceVendorName = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_VENDOR_NAME)
|
||||
self.DeviceModelName = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_MODEL_NAME)
|
||||
self.DeviceFirmwareVersion = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_FIRMWARE_VERSION)
|
||||
self.DeviceVersion = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_VERSION)
|
||||
self.DeviceSerialNumber = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_SERIAL_NUMBER)
|
||||
self.FactorySettingVersion = StringFeature(self.__dev_handle, GxFeatureID.STRING_FACTORY_SETTING_VERSION)
|
||||
self.DeviceUserID = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_USER_ID)
|
||||
self.DeviceLinkSelector = IntFeature(self.__dev_handle, GxFeatureID.INT_DEVICE_LINK_SELECTOR)
|
||||
self.DeviceLinkThroughputLimitMode = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_DEVICE_LINK_THROUGHPUT_LIMIT_MODE)
|
||||
self.DeviceLinkThroughputLimit = IntFeature(self.__dev_handle, GxFeatureID.INT_DEVICE_LINK_THROUGHPUT_LIMIT)
|
||||
self.DeviceLinkCurrentThroughput = IntFeature(self.__dev_handle, GxFeatureID.INT_DEVICE_LINK_CURRENT_THROUGHPUT)
|
||||
self.DeviceReset = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_DEVICE_RESET)
|
||||
self.TimestampTickFrequency = IntFeature(self.__dev_handle, GxFeatureID.INT_TIMESTAMP_TICK_FREQUENCY)
|
||||
self.TimestampLatch = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_TIMESTAMP_LATCH)
|
||||
self.TimestampReset = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_TIMESTAMP_RESET)
|
||||
self.TimestampLatchReset = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_TIMESTAMP_LATCH_RESET)
|
||||
self.TimestampLatchValue = IntFeature(self.__dev_handle, GxFeatureID.INT_TIMESTAMP_LATCH_VALUE)
|
||||
self.DevicePHYVersion = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_PHY_VERSION)
|
||||
self.DeviceTemperatureSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_DEVICE_TEMPERATURE_SELECTOR)
|
||||
self.DeviceTemperature = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_DEVICE_TEMPERATURE)
|
||||
self.DeviceIspFirmwareVersion = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_ISP_FIRMWARE_VERSION)
|
||||
self.LowPowerMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_LOWPOWER_MODE)
|
||||
self.CloseCCD = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_CLOSE_CCD)
|
||||
self.ProductionCode = StringFeature(self.__dev_handle, GxFeatureID.STRING_PRODUCTION_CODE)
|
||||
self.DeviceOriginalName = StringFeature(self.__dev_handle, GxFeatureID.STRING_DEVICE_ORIGINAL_NAME)
|
||||
self.Revision = IntFeature(self.__dev_handle, GxFeatureID.INT_REVISION)
|
||||
self.VersionsSupported = IntFeature(self.__dev_handle, GxFeatureID.INT_VERSIONS_SUPPORTED)
|
||||
self.VersionUsed = IntFeature(self.__dev_handle, GxFeatureID.INT_VERSION_USED)
|
||||
self.TecEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_TEC_ENABLE)
|
||||
self.TecTargetTemperature = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_TEC_TARGET_TEMPERATURE)
|
||||
self.FanEnable = self.TecEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_FAN_ENABLE)
|
||||
self.TemperatureDetectionStatus = IntFeature(self.__dev_handle, GxFeatureID.INT_TEMPERATURE_DETECTION_STATUS)
|
||||
self.FanSpeed = IntFeature(self.__dev_handle, GxFeatureID.INT_FAN_SPEED)
|
||||
self.DeviceHumidity = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_DEVICE_HUMIDITY)
|
||||
self.DevicePressure = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_DEVICE_PRESSURE)
|
||||
self.AirChangeDetectionStatus = IntFeature(self.__dev_handle, GxFeatureID.INT_AIR_CHANGE_DETECTION_STATUS)
|
||||
self.AirTightnessDetectionStatus = IntFeature(self.__dev_handle, GxFeatureID.INT_AIR_TIGHTNESS_DETECTION_STATUS)
|
||||
self.DeviceScanType = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_DEVICE_SCAN_TYPE)
|
||||
|
||||
# ---------------ImageFormat Section--------------------------------
|
||||
self.SensorWidth = IntFeature(self.__dev_handle, GxFeatureID.INT_SENSOR_WIDTH)
|
||||
self.SensorHeight = IntFeature(self.__dev_handle, GxFeatureID.INT_SENSOR_HEIGHT)
|
||||
self.WidthMax = IntFeature(self.__dev_handle, GxFeatureID.INT_WIDTH_MAX)
|
||||
self.HeightMax = IntFeature(self.__dev_handle, GxFeatureID.INT_HEIGHT_MAX)
|
||||
self.OffsetX = IntFeature(self.__dev_handle, GxFeatureID.INT_OFFSET_X)
|
||||
self.OffsetY = IntFeature(self.__dev_handle, GxFeatureID.INT_OFFSET_Y)
|
||||
self.Width = IntFeature(self.__dev_handle, GxFeatureID.INT_WIDTH)
|
||||
self.Height = IntFeature(self.__dev_handle, GxFeatureID.INT_HEIGHT)
|
||||
self.BinningHorizontal = IntFeature(self.__dev_handle, GxFeatureID.INT_BINNING_HORIZONTAL)
|
||||
self.BinningVertical = IntFeature(self.__dev_handle, GxFeatureID.INT_BINNING_VERTICAL)
|
||||
self.DecimationHorizontal = IntFeature(self.__dev_handle, GxFeatureID.INT_DECIMATION_HORIZONTAL)
|
||||
self.DecimationVertical = IntFeature(self.__dev_handle, GxFeatureID.INT_DECIMATION_VERTICAL)
|
||||
self.PixelSize = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_PIXEL_SIZE)
|
||||
self.PixelColorFilter = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_PIXEL_COLOR_FILTER)
|
||||
self.PixelFormat = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_PIXEL_FORMAT)
|
||||
self.ReverseX = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_REVERSE_X)
|
||||
self.ReverseY = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_REVERSE_Y)
|
||||
self.TestPattern = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TEST_PATTERN)
|
||||
self.TestPatternGeneratorSelector = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_TEST_PATTERN_GENERATOR_SELECTOR)
|
||||
self.RegionSendMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_REGION_SEND_MODE)
|
||||
self.RegionMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_REGION_MODE)
|
||||
self.RegionSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_REGION_SELECTOR)
|
||||
self.CenterWidth = IntFeature(self.__dev_handle, GxFeatureID.INT_CENTER_WIDTH)
|
||||
self.CenterHeight = IntFeature(self.__dev_handle, GxFeatureID.INT_CENTER_HEIGHT)
|
||||
self.BinningHorizontalMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_BINNING_HORIZONTAL_MODE)
|
||||
self.BinningVerticalMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_BINNING_VERTICAL_MODE)
|
||||
self.SensorShutterMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SENSOR_SHUTTER_MODE)
|
||||
self.DecimationLineNumber = IntFeature(self.__dev_handle, GxFeatureID.INT_DECIMATION_LINENUMBER)
|
||||
self.SensorDecimationHorizontal = IntFeature(self.__dev_handle, GxFeatureID.INT_SENSOR_DECIMATION_HORIZONTAL)
|
||||
self.SensorDecimationVertical = IntFeature(self.__dev_handle, GxFeatureID.INT_SENSOR_DECIMATION_VERTICAL)
|
||||
self.SensorSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SENSOR_SELECTOR)
|
||||
self.CurrentSensorWidth = IntFeature(self.__dev_handle, GxFeatureID.INT_CURRENT_SENSOR_WIDTH)
|
||||
self.CurrentSensorHeight = IntFeature(self.__dev_handle, GxFeatureID.INT_CURRENT_SENSOR_HEIGHT)
|
||||
self.CurrentSensorOffsetX = IntFeature(self.__dev_handle, GxFeatureID.INT_CURRENT_SENSOR_OFFSETX)
|
||||
self.CurrentSensorOffsetY = IntFeature(self.__dev_handle, GxFeatureID.INT_CURRENT_SENSOR_OFFSETY)
|
||||
self.CurrentSensorWidthMax = IntFeature(self.__dev_handle, GxFeatureID.INT_CURRENT_SENSOR_WIDTHMAX)
|
||||
self.CurrectSensorHeightMax = IntFeature(self.__dev_handle, GxFeatureID.INT_CURRENT_SENSOR_HEIGHTMAX)
|
||||
self.SensorBitDepth = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SENSOR_BIT_DEPTH)
|
||||
self.WatermarkEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_WATERMARK_ENABLE)
|
||||
|
||||
# ---------------TransportLayer Section-------------------------------
|
||||
self.PayloadSize = IntFeature(self.__dev_handle, GxFeatureID.INT_PAYLOAD_SIZE)
|
||||
self.GevCurrentIPConfigurationLLA = BoolFeature(self.__dev_handle,
|
||||
GxFeatureID.BOOL_GEV_CURRENT_IP_CONFIGURATION_LLA)
|
||||
self.GevCurrentIPConfigurationDHCP = BoolFeature(self.__dev_handle,
|
||||
GxFeatureID.BOOL_GEV_CURRENT_IP_CONFIGURATION_DHCP)
|
||||
self.GevCurrentIPConfigurationPersistentIP = BoolFeature(self.__dev_handle,
|
||||
GxFeatureID.BOOL_GEV_CURRENT_IP_CONFIGURATION_PERSISTENT_IP)
|
||||
self.EstimatedBandwidth = IntFeature(self.__dev_handle, GxFeatureID.INT_ESTIMATED_BANDWIDTH)
|
||||
self.GevHeartbeatTimeout = IntFeature(self.__dev_handle, GxFeatureID.INT_GEV_HEARTBEAT_TIMEOUT)
|
||||
self.GevSCPSPacketSize = IntFeature(self.__dev_handle, GxFeatureID.INT_GEV_PACKET_SIZE)
|
||||
self.GevSCPD = IntFeature(self.__dev_handle, GxFeatureID.INT_GEV_PACKET_DELAY)
|
||||
self.GevLinkSpeed = IntFeature(self.__dev_handle, GxFeatureID.INT_GEV_LINK_SPEED)
|
||||
self.DeviceTapGeometry = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_DEVICE_TAP_GEOMETRY)
|
||||
|
||||
# ---------------AcquisitionTrigger Section---------------------------
|
||||
self.AcquisitionMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ACQUISITION_MODE)
|
||||
self.AcquisitionStart = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_ACQUISITION_START)
|
||||
self.AcquisitionStop = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_ACQUISITION_STOP)
|
||||
self.TriggerMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TRIGGER_MODE)
|
||||
self.TriggerSoftware = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_TRIGGER_SOFTWARE)
|
||||
self.TriggerActivation = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TRIGGER_ACTIVATION)
|
||||
self.ExposureTime = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_EXPOSURE_TIME)
|
||||
self.ExposureAuto = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_EXPOSURE_AUTO)
|
||||
self.TriggerFilterRaisingEdge = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_TRIGGER_FILTER_RAISING)
|
||||
self.TriggerFilterFallingEdge = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_TRIGGER_FILTER_FALLING)
|
||||
self.TriggerSource = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TRIGGER_SOURCE)
|
||||
self.ExposureMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_EXPOSURE_MODE)
|
||||
self.TriggerSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TRIGGER_SELECTOR)
|
||||
self.TriggerDelay = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_TRIGGER_DELAY)
|
||||
self.TransferControlMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TRANSFER_CONTROL_MODE)
|
||||
self.TransferOperationMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TRANSFER_OPERATION_MODE)
|
||||
self.TransferStart = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_TRANSFER_START)
|
||||
self.TransferBlockCount = IntFeature(self.__dev_handle, GxFeatureID.INT_TRANSFER_BLOCK_COUNT)
|
||||
self.FrameBufferOverwriteActive = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_FRAMESTORE_COVER_ACTIVE)
|
||||
self.AcquisitionFrameRateMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ACQUISITION_FRAME_RATE_MODE)
|
||||
self.AcquisitionFrameRate = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_ACQUISITION_FRAME_RATE)
|
||||
self.CurrentAcquisitionFrameRate = FloatFeature(self.__dev_handle,
|
||||
GxFeatureID.FLOAT_CURRENT_ACQUISITION_FRAME_RATE)
|
||||
self.FixedPatternNoiseCorrectMode = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_FIXED_PATTERN_NOISE_CORRECT_MODE)
|
||||
self.AcquisitionBurstFrameCount = IntFeature(self.__dev_handle, GxFeatureID.INT_ACQUISITION_BURST_FRAME_COUNT)
|
||||
self.AcquisitionStatusSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ACQUISITION_STATUS_SELECTOR)
|
||||
self.AcquisitionStatus = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_ACQUISITION_STATUS)
|
||||
self.ExposureDelay = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_EXPOSURE_DELAY)
|
||||
self.ExposureOverlapTimeMax = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_EXPOSURE_OVERLAP_TIME_MAX)
|
||||
self.ExposureTimeMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_EXPOSURE_TIME_MODE)
|
||||
self.FrameBufferCount = IntFeature(self.__dev_handle, GxFeatureID.INT_FRAME_BUFFER_COUNT)
|
||||
self.FrameBufferFlush = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_FRAME_BUFFER_FLUSH)
|
||||
self.AcquisitionBurstMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ACQUISITION_BURST_MODE)
|
||||
self.OverlapMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_OVERLAP_MODE)
|
||||
self.MultiSourceSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_MULTISOURCE_SELECTOR)
|
||||
self.MultiSourceEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_MULTISOURCE_ENABLE)
|
||||
self.TriggerCacheEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_TRIGGER_CACHE_ENABLE)
|
||||
|
||||
# ----------------DigitalIO Section----------------------------------
|
||||
self.UserOutputSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_USER_OUTPUT_SELECTOR)
|
||||
self.UserOutputValue = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_USER_OUTPUT_VALUE)
|
||||
self.LineSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_LINE_SELECTOR)
|
||||
self.LineMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_LINE_MODE)
|
||||
self.LineInverter = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_LINE_INVERTER)
|
||||
self.LineSource = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_LINE_SOURCE)
|
||||
self.LineStatus = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_LINE_STATUS)
|
||||
self.LineStatusAll = IntFeature(self.__dev_handle, GxFeatureID.INT_LINE_STATUS_ALL)
|
||||
self.PulseWidth = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_PULSE_WIDTH)
|
||||
self.LineRange = IntFeature(self.__dev_handle, GxFeatureID.INT_LINE_RANGE)
|
||||
self.LineDelay = IntFeature(self.__dev_handle, GxFeatureID.INT_LINE_DELAY)
|
||||
self.LineFilterRaisingEdge = IntFeature(self.__dev_handle, GxFeatureID.INT_LINE_FILTER_RAISING_EDGE)
|
||||
self.LineFilterFallingEdge = IntFeature(self.__dev_handle, GxFeatureID.INT_LINE_FILTER_FALLING_EDGE)
|
||||
|
||||
# ----------------AnalogControls Section----------------------------
|
||||
self.GainAuto = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_GAIN_AUTO)
|
||||
self.GainSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_GAIN_SELECTOR)
|
||||
self.BlackLevelAuto = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_BLACK_LEVEL_AUTO)
|
||||
self.BlackLevelSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_BLACK_LEVEL_SELECTOR)
|
||||
self.BalanceWhiteAuto = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_BALANCE_WHITE_AUTO)
|
||||
self.BalanceRatioSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_BALANCE_RATIO_SELECTOR)
|
||||
self.BalanceRatio = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_BALANCE_RATIO)
|
||||
self.DeadPixelCorrect = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_DEAD_PIXEL_CORRECT)
|
||||
self.Gain = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_GAIN)
|
||||
self.BlackLevel = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_BLACK_LEVEL)
|
||||
self.GammaEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_GAMMA_ENABLE)
|
||||
self.GammaMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_GAMMA_MODE)
|
||||
self.Gamma = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_GAMMA)
|
||||
self.DigitalShift = IntFeature(self.__dev_handle, GxFeatureID.INT_DIGITAL_SHIFT)
|
||||
self.LightSourcePreset = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_LIGHT_SOURCE_PRESET)
|
||||
self.BlackLevelCalibStatus = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_BLACKLEVEL_CALIB_STATUS)
|
||||
self.BlackLevelCalibValue = IntFeature(self.__dev_handle, GxFeatureID.INT_BLACKLEVEL_CALIB_VALUE)
|
||||
self.PGAGain = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_PGA_GAIN)
|
||||
|
||||
# ---------------CustomFeature Section------------------------------
|
||||
self.ExpectedGrayValue = IntFeature(self.__dev_handle, GxFeatureID.INT_GRAY_VALUE)
|
||||
self.AAROIOffsetX = IntFeature(self.__dev_handle, GxFeatureID.INT_AAROI_OFFSETX)
|
||||
self.AAROIOffsetY = IntFeature(self.__dev_handle, GxFeatureID.INT_AAROI_OFFSETY)
|
||||
self.AAROIWidth = IntFeature(self.__dev_handle, GxFeatureID.INT_AAROI_WIDTH)
|
||||
self.AAROIHeight = IntFeature(self.__dev_handle, GxFeatureID.INT_AAROI_HEIGHT)
|
||||
self.AutoGainMin = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_AUTO_GAIN_MIN)
|
||||
self.AutoGainMax = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_AUTO_GAIN_MAX)
|
||||
self.AutoExposureTimeMin = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_AUTO_EXPOSURE_TIME_MIN)
|
||||
self.AutoExposureTimeMax = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_AUTO_EXPOSURE_TIME_MAX)
|
||||
self.ContrastParam = IntFeature(self.__dev_handle, GxFeatureID.INT_CONTRAST_PARAM)
|
||||
self.GammaParam = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_GAMMA_PARAM)
|
||||
self.ColorCorrectionParam = IntFeature(self.__dev_handle, GxFeatureID.INT_COLOR_CORRECTION_PARAM)
|
||||
self.AWBLampHouse = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_AWB_LAMP_HOUSE)
|
||||
self.AWBROIOffsetX = IntFeature(self.__dev_handle, GxFeatureID.INT_AWBROI_OFFSETX)
|
||||
self.AWBROIOffsetY = IntFeature(self.__dev_handle, GxFeatureID.INT_AWBROI_OFFSETY)
|
||||
self.AWBROIWidth = IntFeature(self.__dev_handle, GxFeatureID.INT_AWBROI_WIDTH)
|
||||
self.AWBROIHeight = IntFeature(self.__dev_handle, GxFeatureID.INT_AWBROI_HEIGHT)
|
||||
self.SharpnessMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SHARPNESS_MODE)
|
||||
self.Sharpness = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_SHARPNESS)
|
||||
self.DataFieldSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_USER_DATA_FIELD_SELECTOR)
|
||||
self.DataFieldValue = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_USER_DATA_FIELD_VALUE)
|
||||
self.FlatFieldCorrection = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_FLAT_FIELD_CORRECTION)
|
||||
self.NoiseReductionMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_NOISE_REDUCTION_MODE)
|
||||
self.NoiseReduction = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_NOISE_REDUCTION)
|
||||
self.FFCLoad = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_FFCLOAD)
|
||||
self.FFCSave = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_FFCSAVE)
|
||||
self.StaticDefectCorrection = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_STATIC_DEFECT_CORRECTION)
|
||||
self.NoiseReductionMode2D = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_2D_NOISE_REDUCTION_MODE)
|
||||
self.NoiseReductionMode3D = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_3D_NOISE_REDUCTION_MODE)
|
||||
self.CloseISP = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_CLOSE_ISP)
|
||||
self.StaticDefectCorrectionValueAll = BufferFeature(self.__dev_handle,
|
||||
GxFeatureID.BUFFER_STATIC_DEFECT_CORRECTION_VALUE_ALL)
|
||||
self.StaticDefectCorrectionFlashValue = BufferFeature(self.__dev_handle,
|
||||
GxFeatureID.BUFFER_STATIC_DEFECT_CORRECTION_FLASH_VALUE)
|
||||
self.StaticDefectCorrectionFinish = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_STATIC_DEFECT_CORRECTION_FINISH)
|
||||
self.StaticDefectCorrectionInfo = BufferFeature(self.__dev_handle,
|
||||
GxFeatureID.BUFFER_STATIC_DEFECT_CORRECTION_INFO)
|
||||
self.StripCalibrationStart = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_STRIP_CALIBRATION_START)
|
||||
self.StripCalibrationStop = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_STRIP_CALIBRATION_STOP)
|
||||
self.UserDataFiledValueAll = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_USER_DATA_FILED_VALUE_ALL)
|
||||
self.ShadingCorrectionMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SHADING_CORRECTION_MODE)
|
||||
self.FFCGenerate = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_FFC_GENERATE)
|
||||
self.FFCGenerateStatus = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_FFC_GENERATE_STATUS)
|
||||
self.FFCExpectedGrayValueEnable = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_FFC_EXPECTED_GRAY_VALUE_ENABLE)
|
||||
self.FFCExpectedGray = IntFeature(self.__dev_handle, GxFeatureID.INT_FFC_EXPECTED_GRAY)
|
||||
self.FFCCoeffinientsSize = IntFeature(self.__dev_handle, GxFeatureID.INT_FFC_COEFFICIENTS_SIZE)
|
||||
self.FFCValueAll = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_FFC_VALUE_ALL)
|
||||
self.DSNUSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_DSNU_SELECTOR)
|
||||
self.DSNUGenerate = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_DSNU_GENERATE)
|
||||
self.DSNUGenerateStatus = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_DSNU_GENERATE_STATUS)
|
||||
self.DSNUSave = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_DSNU_SAVE)
|
||||
self.DSNULoad = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_DSNU_LOAD)
|
||||
self.PRNUSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_PRNU_SELECTOR)
|
||||
self.PRNUGenerate = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_PRNU_GENERATE)
|
||||
self.PRNUGenerateStatus = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_PRNU_GENERATE_STATUS)
|
||||
self.PRNUSave = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_PRNU_SAVE)
|
||||
self.PRNULoad = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_PRNU_LOAD)
|
||||
self.DataFieldValueAll = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_USER_DATA_FILED_VALUE_ALL)
|
||||
self.StaticDefectCorrectionCalibStatus = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_STATIC_DEFECT_CORRECTION_CALIB_STATUS)
|
||||
self.FFCFactoryStatus = IntFeature(self.__dev_handle, GxFeatureID.INT_FFC_FACTORY_STATUS)
|
||||
self.DSNUFactoryStatus = IntFeature(self.__dev_handle, GxFeatureID.INT_DSNU_FACTORY_STATUS)
|
||||
self.PRNUFactoryStatus = IntFeature(self.__dev_handle, GxFeatureID.INT_PRNU_FACTORY_STATUS)
|
||||
self.Detect = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_DETECT)
|
||||
self.FFCCoefficient = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_FFC_COEFFICIENT)
|
||||
self.FFCFlashLoad = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_FFCFLASH_LOAD)
|
||||
self.FFCFlashSave = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_FFCFLASH_SAVE)
|
||||
|
||||
# ---------------UserSetControl Section-------------------------------
|
||||
self.UserSetSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_USER_SET_SELECTOR)
|
||||
self.UserSetLoad = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_USER_SET_LOAD)
|
||||
self.UserSetSave = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_USER_SET_SAVE)
|
||||
self.UserSetDefault = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_USER_SET_DEFAULT)
|
||||
self.DataFieldValueAllUsedStatus = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_DATA_FIELD_VALUE_ALL_USED_STATUS)
|
||||
|
||||
# ---------------Event Section----------------------------------------
|
||||
self.EventSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_EVENT_SELECTOR)
|
||||
self.EventNotification = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_EVENT_NOTIFICATION)
|
||||
self.EventExposureEnd = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_EXPOSURE_END)
|
||||
self.EventExposureEndTimestamp = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_EXPOSURE_END_TIMESTAMP)
|
||||
self.EventExposureEndFrameID = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_EXPOSURE_END_FRAME_ID)
|
||||
self.EventBlockDiscard = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_BLOCK_DISCARD)
|
||||
self.EventBlockDiscardTimestamp = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_BLOCK_DISCARD_TIMESTAMP)
|
||||
self.EventOverrun = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_OVERRUN)
|
||||
self.EventOverrunTimestamp = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_OVERRUN_TIMESTAMP)
|
||||
self.EventFrameStartOvertrigger = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_FRAME_START_OVER_TRIGGER)
|
||||
self.EventFrameStartOvertriggerTimestamp = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_FRAME_START_OVER_TRIGGER_TIMESTAMP)
|
||||
self.EventBlockNotEmpty = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_BLOCK_NOT_EMPTY)
|
||||
self.EventBlockNotEmptyTimestamp = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_BLOCK_NOT_EMPTY_TIMESTAMP)
|
||||
self.EventInternalError = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_INTERNAL_ERROR)
|
||||
self.EventInternalErrorTimestamp = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_INTERNAL_ERROR_TIMESTAMP)
|
||||
self.EventFrameBurstStartOvertrigger = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_FRAMEBURSTSTART_OVERTRIGGER)
|
||||
self.EventFrameBurstStartOvertriggerFrameID = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_FRAMEBURSTSTART_OVERTRIGGER_FRAMEID)
|
||||
self.EventFrameBurstStartOvertriggerTimestamp = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_FRAMEBURSTSTART_OVERTRIGGER_TIMESTAMP)
|
||||
self.EventFrameStartWait = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_FRAMESTART_WAIT)
|
||||
self.EventFrameStartWaitTimestamp = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_FRAMESTART_WAIT_TIMESTAMP)
|
||||
self.EventFrameBurstStartWait = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_FRAMEBURSTSTART_WAIT)
|
||||
self.EventFrameBurstStartWaitTimestamp = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_FRAMEBURSTSTART_WAIT_TIMESTAMP)
|
||||
self.EventBlockDiscardFrameID = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_BLOCK_DISCARD_FRAMEID)
|
||||
self.EventFrameStartOvertriggerFrameID = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_FRAMESTART_OVERTRIGGER_FRAMEID)
|
||||
self.EventBlockNotEmptyFrameID = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_BLOCK_NOT_EMPTY_FRAMEID)
|
||||
self.EventFrameStartWaitFrameID = IntFeature(self.__dev_handle, GxFeatureID.INT_EVENT_FRAMESTART_WAIT_FRAMEID)
|
||||
self.EventFrameBurstStartWaitFrameID = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_EVENT_FRAMEBURSTSTART_WAIT_FRAMEID)
|
||||
self.EventSimpleMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_EVENT_SIMPLE_MODE)
|
||||
|
||||
# ---------------LUT Section------------------------------------------
|
||||
self.LUTSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_LUT_SELECTOR)
|
||||
self.LUTValueAll = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_LUT_VALUE_ALL)
|
||||
self.LUTEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_LUT_ENABLE)
|
||||
self.LUTIndex = IntFeature(self.__dev_handle, GxFeatureID.INT_LUT_INDEX)
|
||||
self.LUTValue = IntFeature(self.__dev_handle, GxFeatureID.INT_LUT_VALUE)
|
||||
self.LUTFactoryStatus = IntFeature(self.__dev_handle, GxFeatureID.INT_LUT_FACTORY_STATUS)
|
||||
|
||||
# ---------------ChunkData Section------------------------------------
|
||||
self.ChunkModeActive = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_CHUNK_MODE_ACTIVE)
|
||||
self.ChunkSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_CHUNK_SELECTOR)
|
||||
self.ChunkEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_CHUNK_ENABLE)
|
||||
|
||||
# ---------------Color Transformation Control-------------------------
|
||||
self.ColorTransformationMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_COLOR_TRANSFORMATION_MODE)
|
||||
self.ColorTransformationEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_COLOR_TRANSFORMATION_ENABLE)
|
||||
self.ColorTransformationValueSelector = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_COLOR_TRANSFORMATION_VALUE_SELECTOR)
|
||||
self.ColorTransformationValue = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_COLOR_TRANSFORMATION_VALUE)
|
||||
self.SaturationMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SATURATION_MODE)
|
||||
self.Saturation = IntFeature(self.__dev_handle, GxFeatureID.INT_SATURATION)
|
||||
|
||||
# ---------------CounterAndTimerControl Section-----------------------
|
||||
self.TimerSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TIMER_SELECTOR)
|
||||
self.TimerDuration = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_TIMER_DURATION)
|
||||
self.TimerDelay = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_TIMER_DELAY)
|
||||
self.TimerTriggerSource = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TIMER_TRIGGER_SOURCE)
|
||||
self.CounterSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_COUNTER_SELECTOR)
|
||||
self.CounterEventSource = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_COUNTER_EVENT_SOURCE)
|
||||
self.CounterResetSource = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_COUNTER_RESET_SOURCE)
|
||||
self.CounterResetActivation = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_COUNTER_RESET_ACTIVATION)
|
||||
self.CounterReset = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_COUNTER_RESET)
|
||||
self.CounterTriggerSource = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_COUNTER_TRIGGER_SOURCE)
|
||||
self.CounterDuration = IntFeature(self.__dev_handle, GxFeatureID.INT_COUNTER_DURATION)
|
||||
self.TimerTriggerActivation = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TIMER_TRIGGER_ACTIVATION)
|
||||
self.CounterValue = IntFeature(self.__dev_handle, GxFeatureID.INT_COUNTER_VALUE)
|
||||
|
||||
# ---------------RemoveParameterLimitControl Section------------------
|
||||
self.RemoveParameterLimit = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_REMOVE_PARAMETER_LIMIT)
|
||||
|
||||
# ---------------HDRControl Section------------------
|
||||
self.HDRMode = EnumFeature(self.__dev_handle,GxFeatureID.ENUM_HDR_MODE)
|
||||
self.HDRTargetLongValue = IntFeature(self.__dev_handle, GxFeatureID.INT_HDR_TARGET_LONG_VALUE)
|
||||
self.HDRTargetShortValue = IntFeature(self.__dev_handle, GxFeatureID.INT_HDR_TARGET_SHORT_VALUE)
|
||||
self.HDRTargetMainValue = IntFeature(self.__dev_handle, GxFeatureID.INT_HDR_TARGET_MAIN_VALUE)
|
||||
|
||||
# ---------------MultiGrayControl Section------------------
|
||||
self.MGCMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_MGC_MODE)
|
||||
self.MGCSelector = IntFeature(self.__dev_handle, GxFeatureID.INT_MGC_SELECTOR)
|
||||
self.MGCExposureTime = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_MGC_EXPOSURE_TIME)
|
||||
self.MGCGain = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_MGC_GAIN)
|
||||
|
||||
# ---------------ImageQualityControl Section------------------
|
||||
self.StripedCalibrationInfo = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_STRIPED_CALIBRATION_INFO)
|
||||
self.Contrast = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_CONTRAST)
|
||||
self.HotPixelCorrection = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_HOTPIXEL_CORRECTION)
|
||||
|
||||
# ---------------GyroControl Section------------------
|
||||
self.IMUData = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_IMU_DATA)
|
||||
self.IMUConfigAccRange = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_IMU_CONFIG_ACC_RANGE)
|
||||
self.IMUConfigAccOdrLowPassFilterSwitch = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_IMU_CONFIG_ACC_ODR_LOW_PASS_FILTER_SWITCH)
|
||||
self.IMUConfigAccOdr = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_IMU_CONFIG_ACC_ODR)
|
||||
self.IMUConfigAccOdrLowPassFilterFrequency = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_IMU_CONFIG_ACC_ODR_LOW_PASS_FILTER_FREQUENCY)
|
||||
self.IMUConfigGyroXRange = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_IMU_CONFIG_GYRO_XRANGE)
|
||||
self.IMUConfigGyroYRange = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_IMU_CONFIG_GYRO_YRANGE)
|
||||
self.IMUConfigGyroZRange = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_IMU_CONFIG_GYRO_ZRANGE)
|
||||
self.IMUConfigGyroOdrLowPassFilterSwitch = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_IMU_CONFIG_GYRO_ODR_LOW_PASS_FILTER_SWITCH)
|
||||
self.IMUConfigGyroOdr = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_IMU_CONFIG_GYRO_ODR)
|
||||
self.IMUConfigGyroOdrLowPassFilterFrequency = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_IMU_CONFIG_GYRO_ODR_LOW_PASS_FILTER_FREQUENCY)
|
||||
self.IMURoomTemperature = FloatFeature(self.__dev_handle, GxFeatureID.FLOAT_IMU_ROOM_TEMPERATURE)
|
||||
self.IMUTemperatureOdr = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_IMU_TEMPERATURE_ODR)
|
||||
|
||||
# ---------------FrameBufferControl Section------------------
|
||||
self.FrameBufferCount = IntFeature(self.__dev_handle, GxFeatureID.INT_FRAME_BUFFER_COUNT)
|
||||
self.FrameBufferFlush = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_FRAME_BUFFER_FLUSH)
|
||||
|
||||
# ---------------SerialPortControl Section------------------
|
||||
self.DeviceSerialPortSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SERIALPORT_SELECTOR)
|
||||
self.SerialPortSource = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SERIALPORT_SOURCE)
|
||||
self.DeviceSerialPortBaudRate = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SERIALPORT_BAUDRATE)
|
||||
self.SerialPortDataBits = IntFeature(self.__dev_handle, GxFeatureID.INT_SERIALPORT_DATA_BITS)
|
||||
self.SerialPortStopBits = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SERIALPORT_STOP_BITS)
|
||||
self.SerialPortParity = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SERIALPORT_PARITY)
|
||||
self.TransmitQueueMaxCharacterCount = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_TRANSMIT_QUEUE_MAX_CHARACTER_COUNT)
|
||||
self.TransmitQueueCurrentCharacterCount = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_TRANSMIT_QUEUE_CURRENT_CHARACTER_COUNT)
|
||||
self.ReceiveQueueMaxCharacterCount = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_RECEIVE_QUEUE_MAX_CHARACTER_COUNT)
|
||||
self.ReceiveQueueCurrentCharacterCount = IntFeature(self.__dev_handle,
|
||||
GxFeatureID.INT_RECEIVE_QUEUE_CURRENT_CHARACTER_COUNT)
|
||||
self.ReceiveFramingErrorCount = IntFeature(self.__dev_handle, GxFeatureID.INT_RECEIVE_FRAMING_ERROR_COUNT)
|
||||
self.ReceiveParityErrorCount = IntFeature(self.__dev_handle, GxFeatureID.INT_RECEIVE_PARITY_ERROR_COUNT)
|
||||
self.ReceiveQueueClear = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_RECEIVE_QUEUE_CLEAR)
|
||||
self.SerialPortData = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_SERIALPORT_DATA)
|
||||
self.SerialPortDataLength = IntFeature(self.__dev_handle, GxFeatureID.INT_SERIALPORT_DATA_LENGTH)
|
||||
self.SerialPortDetectionStatus = IntFeature(self.__dev_handle, GxFeatureID.INT_SERIAL_PORT_DETECTION_STATUS)
|
||||
|
||||
# ---------------CoaXPress Section------------------
|
||||
self.CxpLinkConfiguration = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_CXP_LINK_CONFIGURATION)
|
||||
self.CxpLinkConfigurationPreferred = EnumFeature(self.__dev_handle,
|
||||
GxFeatureID.ENUM_CXP_LINK_CONFIGURATION_PREFERRED)
|
||||
self.CxpLinkConfigurationStatus = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_CXP_LINK_CONFIGURATION_STATUS)
|
||||
self.Image1StreamID = IntFeature(self.__dev_handle, GxFeatureID.INT_IMAGE1_STREAM_ID)
|
||||
self.CxpConnectionSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_CXP_CONNECTION_SELECTOR)
|
||||
self.CxpConnectionTestMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_CXP_CONNECTION_TEST_MODE)
|
||||
self.CxpConnectionTestErrorCount = IntFeature(self.__dev_handle, GxFeatureID.INT_RECEIVE_FRAMING_ERROR_COUNT)
|
||||
self.CxpConnectionTestPacketRxCount = IntFeature(self.__dev_handle, GxFeatureID.INT_RECEIVE_FRAMING_ERROR_COUNT)
|
||||
self.CxpConnectionTestPacketTxCount = IntFeature(self.__dev_handle, GxFeatureID.INT_RECEIVE_FRAMING_ERROR_COUNT)
|
||||
|
||||
# ---------------SequencerControl Section------------------
|
||||
self.SequencerMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SEQUENCER_MODE)
|
||||
self.SequencerConfigurationMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SEQUENCER_CONFIGURATION_MODE)
|
||||
self.SequencerFeatureSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SEQUENCER_FEATURE_SELECTOR)
|
||||
self.SequencerFeatureEnable = BoolFeature(self.__dev_handle, GxFeatureID.BOOL_SEQUENCER_FEATURE_ENABLE)
|
||||
self.SequencerSetSelector = IntFeature(self.__dev_handle, GxFeatureID.INT_SEQUENCER_SET_SELECTOR)
|
||||
self.SequencerSetCount = IntFeature(self.__dev_handle, GxFeatureID.INT_SEQUENCER_SET_COUNT)
|
||||
self.SequencerSetActive = IntFeature(self.__dev_handle, GxFeatureID.INT_SEQUENCER_SET_ACTIVE)
|
||||
self.SequencerSetReset = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_SEQUENCER_SET_RESET)
|
||||
self.SequencerPathSelector = IntFeature(self.__dev_handle, GxFeatureID.INT_SEQUENCER_PATH_SELECTOR)
|
||||
self.SequencerSetNext = IntFeature(self.__dev_handle, GxFeatureID.INT_SEQUENCER_SET_NEXT)
|
||||
self.SequencerTriggerSource = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_SEQUENCER_TRIGGER_SOURCE)
|
||||
self.SequencerSetSave = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_SEQUENCER_SET_SAVE)
|
||||
self.SequencerSetLoad = CommandFeature(self.__dev_handle, GxFeatureID.COMMAND_SEQUENCER_SET_LOAD)
|
||||
|
||||
# ---------------EnoderControl Section------------------
|
||||
self.EncoderSelector = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ENCODER_SELECTOR)
|
||||
self.EncoderDirection = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ENCODER_DIRECTION)
|
||||
self.EncoderValue = IntFeature(self.__dev_handle, GxFeatureID.INT_ENCODER_VALUE)
|
||||
self.EncoderSourceA = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ENCODER_SOURCEA)
|
||||
self.EncoderSourceB = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ENCODER_SOURCEB)
|
||||
self.EncoderMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_ENCODER_MODE)
|
||||
self.__get_stream_handle()
|
||||
|
||||
def __get_stream_handle(self):
|
||||
"""
|
||||
:brief Get stream handle and create stream object
|
||||
:return:
|
||||
"""
|
||||
status, data_stream_num = gx_data_stream_number_from_device(self.__dev_handle)
|
||||
StatusProcessor.process(status, 'Device', '__get_stream_handle')
|
||||
|
||||
for index in range(data_stream_num):
|
||||
status, stream_handle = gx_get_data_stream_handle_from_device(self.__dev_handle, index + 1)
|
||||
StatusProcessor.process(status, 'Device', '__get_stream_handle')
|
||||
|
||||
self.data_stream.append(DataStream( self.__dev_handle, stream_handle))
|
||||
|
||||
def get_stream_channel_num(self):
|
||||
"""
|
||||
:brief Get the number of stream channels supported by the current device.
|
||||
:return: the number of stream channels
|
||||
"""
|
||||
return len(self.data_stream)
|
||||
|
||||
|
||||
def get_parent_interface(self):
|
||||
"""
|
||||
:brief Get interface
|
||||
:return: Interface
|
||||
"""
|
||||
return self.__interface_obj
|
||||
|
||||
|
||||
def close_device(self):
|
||||
"""
|
||||
:brief close device, close device handle
|
||||
:return: None
|
||||
"""
|
||||
status = gx_close_device(self.__dev_handle)
|
||||
StatusProcessor.process(status, 'Device', 'close_device')
|
||||
self.__dev_handle = None
|
||||
self.__py_offline_callback = None
|
||||
self.__offline_callback_handle = None
|
||||
self.__py_feature_callback = None
|
||||
|
||||
def get_stream_number(self):
|
||||
"""
|
||||
:brief Get the number of stream channels supported by the current device.
|
||||
:return: the number of stream channels
|
||||
"""
|
||||
return len(self.__data_stream_handle)
|
||||
|
||||
def get_stream(self, stream_index):
|
||||
"""
|
||||
:brief Get stream object
|
||||
:param stream_index: stream index
|
||||
:return: stream object
|
||||
"""
|
||||
if not isinstance(stream_index, INT_TYPE):
|
||||
raise ParameterTypeError("Device.get_stream: "
|
||||
"Expected stream_index type is int, not %s" % type(stream_index))
|
||||
|
||||
if stream_index < 1:
|
||||
print("Device.get_stream: stream_index must start from 1")
|
||||
return None
|
||||
elif stream_index > UNSIGNED_INT_MAX:
|
||||
print("Device.get_stream: stream_index maximum: %s" % hex(len(self.data_stream)).__str__())
|
||||
return None
|
||||
|
||||
if len( self.data_stream) < stream_index:
|
||||
raise NotFoundDevice("Device.get_stream: invalid index")
|
||||
|
||||
return self.data_stream[stream_index - 1]
|
||||
|
||||
def get_local_device_feature_control(self):
|
||||
"""
|
||||
:brief Get local device layer feature control object
|
||||
:return: Local device layer feature control object
|
||||
"""
|
||||
status, local_handle = gx_local_device_handle_from_device( self.__dev_handle)
|
||||
StatusProcessor.process(status, 'Device', 'register_device_offline_callback')
|
||||
feature_control = FeatureControl( local_handle)
|
||||
return feature_control
|
||||
|
||||
def get_remote_device_feature_control(self):
|
||||
"""
|
||||
:brief Get remote device layer feature control object
|
||||
:return: Remote device layer feature control object
|
||||
"""
|
||||
feature_control = FeatureControl( self.__dev_handle)
|
||||
return feature_control
|
||||
|
||||
def register_device_offline_callback(self, callback_func):
|
||||
"""
|
||||
:brief Register the device offline event callback function.
|
||||
Interface is obsolete.
|
||||
:param callback_func: callback function
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(callback_func, types.FunctionType):
|
||||
raise ParameterTypeError("Device.register_device_offline_callback: "
|
||||
"Expected callback type is function not %s" % type(callback_func))
|
||||
|
||||
status, offline_callback_handle = gx_register_device_offline_callback \
|
||||
(self.__dev_handle, self.__c_offline_callback)
|
||||
StatusProcessor.process(status, 'Device', 'register_device_offline_callback')
|
||||
|
||||
# callback will not recorded when register callback failed.
|
||||
self.__py_offline_callback = callback_func
|
||||
self.__offline_callback_handle = offline_callback_handle
|
||||
|
||||
def unregister_device_offline_callback(self):
|
||||
"""
|
||||
:brief Unregister the device offline event callback function.
|
||||
Interface is obsolete.
|
||||
:return: none
|
||||
"""
|
||||
status = gx_unregister_device_offline_callback(self.__dev_handle, self.__offline_callback_handle)
|
||||
StatusProcessor.process(status, 'Device', 'unregister_device_offline_callback')
|
||||
self.__py_offline_callback = None
|
||||
self.__offline_callback_handle = None
|
||||
|
||||
def __on_device_offline_callback(self, c_user_param):
|
||||
"""
|
||||
:brief Device offline event callback function with an unused c_void_p.
|
||||
Interface is obsolete.
|
||||
:return: none
|
||||
"""
|
||||
self.__py_offline_callback()
|
||||
|
||||
|
||||
# The following interfaces are obsolete.
|
||||
def stream_on(self, stream_index = 0):
|
||||
"""
|
||||
:brief send start command, camera start transmission image data
|
||||
Interface is obsolete.
|
||||
:return: none
|
||||
"""
|
||||
status = gx_send_command(self.__dev_handle, GxFeatureID.COMMAND_ACQUISITION_START)
|
||||
StatusProcessor.process(status, 'Device', 'stream_on')
|
||||
|
||||
payload_size = self.data_stream[0].get_payload_size()
|
||||
self.data_stream[0].set_payload_size(payload_size)
|
||||
self.data_stream[0].set_acquisition_flag(True)
|
||||
|
||||
def stream_off(self,stream_index = 0):
|
||||
"""
|
||||
:brief send stop command, camera stop transmission image data
|
||||
Interface is obsolete.
|
||||
:return: none
|
||||
"""
|
||||
status = gx_send_command(self.__dev_handle, GxFeatureID.COMMAND_ACQUISITION_STOP)
|
||||
StatusProcessor.process(status, 'Device', 'stream_off')
|
||||
self.data_stream[0].set_acquisition_flag(False)
|
||||
|
||||
def export_config_file(self, file_path):
|
||||
"""
|
||||
:brief Export the current configuration file
|
||||
Interface is obsolete.
|
||||
:param file_path: file path(type: str)
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(file_path, str):
|
||||
raise ParameterTypeError("Device.export_config_file: "
|
||||
"Expected file_path type is str, not %s" % type(file_path))
|
||||
|
||||
status = gx_export_config_file(self.__dev_handle, file_path)
|
||||
StatusProcessor.process(status, 'Device', 'export_config_file')
|
||||
|
||||
def import_config_file(self, file_path, verify=False):
|
||||
"""
|
||||
:brief Imported configuration file
|
||||
Interface is obsolete.
|
||||
:param file_path: file path(type: str)
|
||||
:param verify: If this value is true, all the imported values will be read out
|
||||
and checked for consistency(type: bool)
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(file_path, str):
|
||||
raise ParameterTypeError("Device.import_config_file: "
|
||||
"Expected file_path type is str, not %s" % type(file_path))
|
||||
|
||||
if not isinstance(verify, bool):
|
||||
raise ParameterTypeError("Device.import_config_file: "
|
||||
"Expected verify type is bool, not %s" % type(verify))
|
||||
|
||||
status = gx_import_config_file(self.__dev_handle, file_path, verify)
|
||||
StatusProcessor.process(status, 'Device', 'import_config_file')
|
||||
|
||||
def register_device_feature_callback(self, callback_func, feature_id, args):
|
||||
"""
|
||||
:brief Register the device feature event callback function.
|
||||
:param callback_func: callback function
|
||||
:param feature_id: feature id
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(callback_func, types.FunctionType):
|
||||
raise ParameterTypeError("Device.register_device_feature_callback: "
|
||||
"Expected callback type is function not %s" % type(callback_func))
|
||||
|
||||
if feature_id not in vars(GxFeatureID).values():
|
||||
raise ParameterTypeError("Device.register_device_feature_callback: "
|
||||
"Expected feature id is in GxEventSectionEntry not %s" % feature_id)
|
||||
|
||||
status, feature_callback_handle = gx_register_feature_callback \
|
||||
(self.__dev_handle, self.__c_feature_callback, feature_id, args)
|
||||
StatusProcessor.process(status, 'Device', 'register_device_feature_callback')
|
||||
|
||||
# callback will not recorded when register callback failed.
|
||||
self.__py_feature_callback = callback_func
|
||||
return feature_callback_handle
|
||||
|
||||
def register_device_feature_callback_by_string(self, callback_func, feature_name, args):
|
||||
"""
|
||||
:brief Register the device feature event callback function.
|
||||
:param callback_func: callback function
|
||||
:param feature_id: feature id
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(callback_func, types.FunctionType):
|
||||
raise ParameterTypeError("Device.register_device_feature_callback: "
|
||||
"Expected callback type is function not %s" % type(callback_func))
|
||||
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("Device.register_device_feature_callback: "
|
||||
"Expected feature id is in GxEventSectionEntry not %s" % feature_name)
|
||||
|
||||
status, feature_callback_handle = gx_register_feature_call_back_by_string \
|
||||
(self.__dev_handle, self.__c_feature_callback, feature_name, args)
|
||||
StatusProcessor.process(status, 'Device', 'register_device_feature_callback')
|
||||
|
||||
# callback will not recorded when register callback failed.
|
||||
self.__py_feature_callback = callback_func
|
||||
return feature_callback_handle
|
||||
|
||||
def unregister_device_feature_callback(self, feature_id, feature_callback_handle):
|
||||
"""
|
||||
:brief Unregister the device feature event callback function.
|
||||
:return: none
|
||||
"""
|
||||
if feature_id not in vars(GxFeatureID).values():
|
||||
raise ParameterTypeError("Device.unregister_device_feature_callback: "
|
||||
"Expected feature id is in GxEventSectionEntry not %s" % feature_id)
|
||||
|
||||
status = gx_unregister_feature_callback(self.__dev_handle, feature_id, feature_callback_handle)
|
||||
StatusProcessor.process(status, 'Device', 'unregister_device_feature_callback')
|
||||
|
||||
self.__py_feature_callback = None
|
||||
|
||||
def unregister_device_feature_callback_by_string(self, feature_name, feature_callback_handle):
|
||||
"""
|
||||
:brief Unregister the device feature event callback function.
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("Device.unregister_device_feature_callback: "
|
||||
"Expected feature id is in GxEventSectionEntry not %s" % feature_name)
|
||||
|
||||
status = gx_unregister_feature_call_back_by_string(self.__dev_handle, feature_name, feature_callback_handle)
|
||||
StatusProcessor.process(status, 'Device', 'unregister_device_feature_callback')
|
||||
|
||||
self.__py_feature_callback = None
|
||||
|
||||
def __on_device_feature_callback(self, c_feature_id, c_user_param):
|
||||
"""
|
||||
:brief Device feature event callback function with an unused c_void_p.
|
||||
:return: none
|
||||
"""
|
||||
self.__py_feature_callback(c_feature_id, c_user_param)
|
||||
|
||||
|
||||
def read_remote_device_port(self, address, buff, size):
|
||||
"""
|
||||
:brief Read Remote Regesiter
|
||||
Interface is obsolete.
|
||||
:param address: The address of the register to be read(type: int)
|
||||
:param bytearray: The data to be read from register(type: buffer)
|
||||
:return: Read Remote Regesiter Data Buff
|
||||
"""
|
||||
if not isinstance(address, INT_TYPE):
|
||||
raise ParameterTypeError("Device.read_remote_device_port: "
|
||||
"Expected address type is int, not %s" % type(address))
|
||||
|
||||
if not isinstance(size, INT_TYPE):
|
||||
raise ParameterTypeError("Device.read_remote_device_port: "
|
||||
"Expected size type is int, not %s" % type(size))
|
||||
|
||||
status, read_result = gx_read_remote_device_port(self.__dev_handle, address, buff, size)
|
||||
StatusProcessor.process(status, 'Device', 'read_remote_device_port')
|
||||
|
||||
return status
|
||||
|
||||
def write_remote_device_port(self, address, buf, size):
|
||||
"""
|
||||
:brief Write remote register
|
||||
Interface is obsolete.
|
||||
:param address: The address of the register to be written.(type: int)
|
||||
:param bytearray: The data to be written from user.(type: buffer)
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(address, INT_TYPE):
|
||||
raise ParameterTypeError("Device.write_remote_device_port: "
|
||||
"Expected address type is int, not %s" % type(address))
|
||||
|
||||
status, r_size = gx_write_remote_device_port(self.__dev_handle, address, buf, size)
|
||||
StatusProcessor.process(status, 'Device', 'write_remote_device_port')
|
||||
|
||||
def read_remote_device_port_stacked(self, entries, size):
|
||||
"""
|
||||
:brief Batch read the value of a user-specified register (only for registers with a command value of 4 bytes in length)
|
||||
:entries [in]Batch read register addresses and values
|
||||
[out]Read the data to the corresponding register
|
||||
:read_num [in]Read the number of device registers
|
||||
[out]The number of registers that were successfully read
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(size, INT_TYPE):
|
||||
raise ParameterTypeError("Device.set_read_remote_device_port_stacked: "
|
||||
"Expected size type is int, not %s" % type(size))
|
||||
|
||||
status = gx_set_read_remote_device_port_stacked(self.__dev_handle, entries, size)
|
||||
status = dll.GXReadRemoteDevicePort(handle_c, address_c, byref(buff), byref(size_c))
|
||||
StatusProcessor.process(status, 'Device', 'read_remote_device_port_stacked')
|
||||
|
||||
return status
|
||||
|
||||
def write_remote_device_port_stacked(self, entries, size):
|
||||
"""
|
||||
:brief Batch read the value of a user-specified register (only for registers with a command value of 4 bytes in length)
|
||||
:entries [in]The address and value of the batch write register
|
||||
:read_num [in]Sets the number of device registers
|
||||
[out]The number of registers that were successfully written
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(size, INT_TYPE):
|
||||
raise ParameterTypeError("Device.set_read_remote_device_port_stacked: "
|
||||
"Expected size type is int, not %s" % type(size))
|
||||
|
||||
status = gx_set_write_remote_device_port_stacked(self.__dev_handle, entries, size)
|
||||
StatusProcessor.process(status, 'Device', 'set_write_remote_device_port_stacked')
|
||||
|
||||
def create_image_process_config(self):
|
||||
"""
|
||||
:brief Create an image processing configuration parameter object
|
||||
:return: image processing configuration object
|
||||
"""
|
||||
color_correction_param = self.__color_correction_param
|
||||
|
||||
remote_feature_control = self.get_remote_device_feature_control()
|
||||
if (remote_feature_control.is_implemented("ColorCorrectionParam")):
|
||||
if remote_feature_control.is_readable("ColorCorrectionParam"):
|
||||
color_correction_param = remote_feature_control.get_int_feature("ColorCorrectionParam").get()
|
||||
else:
|
||||
raise UnexpectedError("ColorCorrectionParam does not support read")
|
||||
|
||||
image_process_config = ImageProcessConfig(color_correction_param)
|
||||
return image_process_config
|
||||
|
||||
def set_device_persistent_ip_address(self, ip, subnet_mask, default_gate_way):
|
||||
"""
|
||||
brief: Set the persistent IP information of the device
|
||||
return: Success: feature name
|
||||
Failed: convert feature ID to string
|
||||
"""
|
||||
status = gx_set_device_persistent_ip_address(self.__dev_handle, ip, subnet_mask, default_gate_way)
|
||||
StatusProcessor.process(status, 'Device', 'set_device_persistent_ip_address')
|
||||
|
||||
def get_device_persistent_ip_address(self):
|
||||
"""
|
||||
brief: Set the persistent IP information of the device
|
||||
return: Success: feature name
|
||||
Failed: convert feature ID to string
|
||||
"""
|
||||
status, ip, subnet_mask, default_gateway = gx_get_device_persistent_ip_address(self.__dev_handle)
|
||||
StatusProcessor.process(status, 'Device', 'get_device_persistent_ip_address')
|
||||
return status, ip, subnet_mask, default_gateway
|
||||
|
||||
|
||||
class GEVDevice(Device):
|
||||
def __init__(self, handle, interface_obj):
|
||||
self.__dev_handle = handle
|
||||
Device.__init__(self, self.__dev_handle, interface_obj)
|
||||
self.GevCurrentIPConfigurationLLA = BoolFeature(self.__dev_handle,
|
||||
GxFeatureID.BOOL_GEV_CURRENT_IP_CONFIGURATION_LLA)
|
||||
self.GevCurrentIPConfigurationDHCP = BoolFeature(self.__dev_handle,
|
||||
GxFeatureID.BOOL_GEV_CURRENT_IP_CONFIGURATION_DHCP)
|
||||
self.GevCurrentIPConfigurationPersistentIP = BoolFeature(self.__dev_handle,
|
||||
GxFeatureID.BOOL_GEV_CURRENT_IP_CONFIGURATION_PERSISTENT_IP)
|
||||
self.EstimatedBandwidth = IntFeature(self.__dev_handle, GxFeatureID.INT_ESTIMATED_BANDWIDTH)
|
||||
self.GevHeartbeatTimeout = IntFeature(self.__dev_handle, GxFeatureID.INT_GEV_HEARTBEAT_TIMEOUT)
|
||||
self.GevSCPSPacketSize = IntFeature(self.__dev_handle, GxFeatureID.INT_GEV_PACKET_SIZE)
|
||||
self.GevSCPD = IntFeature(self.__dev_handle, GxFeatureID.INT_GEV_PACKET_DELAY)
|
||||
self.GevLinkSpeed = IntFeature(self.__dev_handle, GxFeatureID.INT_GEV_LINK_SPEED)
|
||||
self.DeviceCommandTimeout = IntFeature(self.__dev_handle, GxFeatureID.INT_COMMAND_TIMEOUT)
|
||||
self.DeviceCommandRetryCount = IntFeature(self.__dev_handle, GxFeatureID.INT_COMMAND_RETRY_COUNT)
|
||||
|
||||
class U3VDevice(Device):
|
||||
"""
|
||||
The U3VDevice class inherits from the Device class. In addition to inheriting the properties of the Device,
|
||||
the U3V Device has special attributes such as bandwidth limitation, URBSetting, frame info, etc.
|
||||
"""
|
||||
|
||||
def __init__(self, handle, interface_obj):
|
||||
self.__dev_handle = handle
|
||||
Device.__init__(self, self.__dev_handle, interface_obj)
|
||||
|
||||
|
||||
class U2Device(Device):
|
||||
"""
|
||||
The U2Device class inherits from the Device class
|
||||
"""
|
||||
|
||||
def __init__(self, handle, interface_obj):
|
||||
self.__dev_handle = handle
|
||||
Device.__init__(self, self.__dev_handle, interface_obj)
|
||||
self.AcquisitionSpeedLevel = IntFeature(self.__dev_handle, GxFeatureID.INT_ACQUISITION_SPEED_LEVEL)
|
||||
self.AcquisitionFrameCount = IntFeature(self.__dev_handle, GxFeatureID.INT_ACQUISITION_FRAME_COUNT)
|
||||
self.TriggerSwitch = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_TRIGGER_SWITCH)
|
||||
self.UserOutputMode = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_USER_OUTPUT_MODE)
|
||||
self.StrobeSwitch = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_STROBE_SWITCH)
|
||||
self.ADCLevel = IntFeature(self.__dev_handle, GxFeatureID.INT_ADC_LEVEL)
|
||||
self.HBlanking = IntFeature(self.__dev_handle, GxFeatureID.INT_H_BLANKING)
|
||||
self.VBlanking = IntFeature(self.__dev_handle, GxFeatureID.INT_V_BLANKING)
|
||||
self.UserPassword = StringFeature(self.__dev_handle, GxFeatureID.STRING_USER_PASSWORD)
|
||||
self.VerifyPassword = StringFeature(self.__dev_handle, GxFeatureID.STRING_VERIFY_PASSWORD)
|
||||
self.UserData = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_USER_DATA)
|
||||
self.AALightEnvironment = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_AA_LIGHT_ENVIRONMENT)
|
||||
self.FrameInformation = BufferFeature(self.__dev_handle, GxFeatureID.BUFFER_FRAME_INFORMATION)
|
||||
self.ImageGrayRaiseSwitch = EnumFeature(self.__dev_handle, GxFeatureID.ENUM_IMAGE_GRAY_RAISE_SWITCH)
|
||||
|
||||
|
@ -0,0 +1,752 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .gxiapi import *
|
||||
from .StatusProcessor import *
|
||||
from .Interface import *
|
||||
from .Device import *
|
||||
from .ImageFormatConvert import *
|
||||
from .ImageProcess import *
|
||||
from .Exception import *
|
||||
import types
|
||||
|
||||
if sys.version_info.major > 2:
|
||||
INT_TYPE = int
|
||||
else:
|
||||
INT_TYPE = (int, long)
|
||||
|
||||
class DeviceManager(object):
|
||||
__instance_num = 0
|
||||
|
||||
def set_log_type(self, log_type):
|
||||
"""
|
||||
:brief Set whether logs of the specified type can be sent
|
||||
:param log_type: log type,See detail in GxLogTypeList
|
||||
:return: status: State return value, See detail in GxStatusList
|
||||
"""
|
||||
if not isinstance(log_type, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.set_log_type: "
|
||||
"Expected log type is int, not %s" % type(log_type))
|
||||
|
||||
status= gx_set_log_type(log_type)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'set_log_type')
|
||||
|
||||
def get_log_type(self):
|
||||
"""
|
||||
:brief Gets whether logs of the specified type can be sent
|
||||
:return: status: State return value, See detail in GxStatusList
|
||||
log_type: log type,See detail in GxLogTypeList
|
||||
"""
|
||||
status,log_type = gx_get_log_type()
|
||||
StatusProcessor.process(status, 'DeviceManager', 'get_log_type')
|
||||
self.__log_type = log_type
|
||||
|
||||
return self.__log_type
|
||||
|
||||
def __new__(cls, *args, **kw):
|
||||
cls.__instance_num += 1
|
||||
status = gx_init_lib()
|
||||
StatusProcessor.process(status, 'DeviceManager', 'init_lib')
|
||||
return object.__new__(cls, *args)
|
||||
|
||||
def __init__(self):
|
||||
self.__device_num = 0
|
||||
self.__device_info_list = []
|
||||
self.__interface_info_list = []
|
||||
self.__interface_num = 0
|
||||
|
||||
def __del__(self):
|
||||
self.__class__.__instance_num -= 1
|
||||
if self.__class__.__instance_num <= 0:
|
||||
status = gx_close_lib()
|
||||
StatusProcessor.process(status, 'DeviceManager', 'close_lib')
|
||||
|
||||
def __create_device(self, device_class, device_handle):
|
||||
status, interface_handle = gx_get_parent_interface_from_device(device_handle)
|
||||
StatusProcessor.process(status, 'DeviceManager', '__create_device')
|
||||
|
||||
index = 0
|
||||
for interface_item in self.__interface_info_list:
|
||||
if interface_item['handle'] == interface_handle:
|
||||
break
|
||||
++index
|
||||
|
||||
if device_class == GxDeviceClassList.U3V:
|
||||
return U3VDevice(device_handle, Interface(interface_handle, self.__interface_info_list[index]))
|
||||
elif device_class == GxDeviceClassList.USB2:
|
||||
return U2Device(device_handle, Interface(interface_handle, self.__interface_info_list[index]))
|
||||
elif device_class == GxDeviceClassList.GEV:
|
||||
return GEVDevice(device_handle, Interface(interface_handle, self.__interface_info_list[index]))
|
||||
elif device_class == GxDeviceClassList.CXP:
|
||||
return Device(device_handle, Interface(interface_handle, self.__interface_info_list[index]))
|
||||
else:
|
||||
raise NotFoundDevice("DeviceManager.__create_device: Does not support this device type.")
|
||||
|
||||
def __get_device_info_list(self, base_info, ip_info, num):
|
||||
"""
|
||||
:brief Convert GxDeviceBaseInfo and GxDeviceIPInfo to device info list
|
||||
:param base_info: device base info list[GxDeviceBaseInfo]
|
||||
:param ip_info: device ip info list[GxDeviceIPInfo]
|
||||
:param num: device number
|
||||
:return: device info list
|
||||
"""
|
||||
device_info_list = []
|
||||
for i in range(num):
|
||||
device_info_list.append({
|
||||
'index': i + 1,
|
||||
'vendor_name': string_decoding(base_info[i].vendor_name),
|
||||
'model_name': string_decoding(base_info[i].model_name),
|
||||
'sn': string_decoding(base_info[i].serial_number),
|
||||
'display_name': string_decoding(base_info[i].display_name),
|
||||
'device_id': string_decoding(base_info[i].device_id),
|
||||
'user_id': string_decoding(base_info[i].user_id),
|
||||
'access_status': base_info[i].access_status,
|
||||
'device_class': base_info[i].device_class,
|
||||
'mac': string_decoding(ip_info[i].mac),
|
||||
'ip': string_decoding(ip_info[i].ip),
|
||||
'subnet_mask': string_decoding(ip_info[i].subnet_mask),
|
||||
'gateway': string_decoding(ip_info[i].gateway),
|
||||
'nic_mac': string_decoding(ip_info[i].nic_mac),
|
||||
'nic_ip': string_decoding(ip_info[i].nic_ip),
|
||||
'nic_subnet_mask': string_decoding(ip_info[i].nic_subnet_mask),
|
||||
'nic_gateWay': string_decoding(ip_info[i].nic_gateWay),
|
||||
'nic_description': string_decoding(ip_info[i].nic_description)
|
||||
})
|
||||
|
||||
return device_info_list
|
||||
|
||||
def __get_interface_info_list(self):
|
||||
"""
|
||||
:brief Get GXInterfaceInfo and Convert GXInterfaceInfo to interface info list
|
||||
:return: interface info list
|
||||
"""
|
||||
status,interface_number = gx_get_interface_number()
|
||||
StatusProcessor.process(status, 'DeviceManager', '__get_interface_info_list')
|
||||
|
||||
interface_info_list = []
|
||||
for nindex in range(interface_number):
|
||||
status, interface_info = gx_get_interface_info(nindex+1)
|
||||
StatusProcessor.process(status, 'DeviceManager', '__get_interface_info_list')
|
||||
|
||||
status, interface_handle = gx_get_interface_handle(nindex+1)
|
||||
StatusProcessor.process(status, 'DeviceManager', '__get_interface_info_list')
|
||||
|
||||
if GxTLClassList.TL_TYPE_CXP == interface_info.TLayer_type:
|
||||
interface_info_list.append({
|
||||
'handle' : interface_handle,
|
||||
'type' : GxTLClassList.TL_TYPE_CXP,
|
||||
'display_name' : string_decoding( interface_info.IF_info.CXP_interface_info.display_name),
|
||||
'interface_id' : string_decoding( interface_info.IF_info.CXP_interface_info.interface_id),
|
||||
'serial_number': string_decoding( interface_info.IF_info.CXP_interface_info.serial_number),
|
||||
'description' : '',
|
||||
'init_flag' : interface_info.IF_info.CXP_interface_info.init_flag,
|
||||
'PCIE_info' : interface_info.IF_info.CXP_interface_info.PCIE_info,
|
||||
'reserved' : array_decoding(interface_info.IF_info.CXP_interface_info.reserved),
|
||||
})
|
||||
elif GxTLClassList.TL_TYPE_GEV == interface_info.TLayer_type:
|
||||
interface_info_list.append({
|
||||
'handle' : interface_handle,
|
||||
'type' : GxTLClassList.TL_TYPE_GEV,
|
||||
'display_name' : string_decoding( interface_info.IF_info.GEV_interface_info.display_name),
|
||||
'interface_id' : string_decoding(interface_info.IF_info.GEV_interface_info.interface_id),
|
||||
'serial_number' : string_decoding(interface_info.IF_info.GEV_interface_info.serial_number),
|
||||
'description' : string_decoding(interface_info.IF_info.GEV_interface_info.description),
|
||||
'init_flag' : 0,
|
||||
'PCIE_info' : 0,
|
||||
'reserved' : array_decoding(interface_info.IF_info.GEV_interface_info.reserved),
|
||||
})
|
||||
elif GxTLClassList.TL_TYPE_U3V == interface_info.TLayer_type:
|
||||
interface_info_list.append({
|
||||
'handle' : interface_handle,
|
||||
'type' : GxTLClassList.TL_TYPE_U3V,
|
||||
'display_name' : string_decoding( interface_info.IF_info.U3V_interface_info.display_name),
|
||||
'interface_id' : string_decoding(interface_info.IF_info.U3V_interface_info.interface_id),
|
||||
'serial_number' : string_decoding(interface_info.IF_info.U3V_interface_info.serial_number),
|
||||
'description' : string_decoding(interface_info.IF_info.U3V_interface_info.description),
|
||||
'init_flag' : 0,
|
||||
'PCIE_info' : 0,
|
||||
'reserved' : array_decoding(interface_info.IF_info.U3V_interface_info.reserved),
|
||||
})
|
||||
elif GxTLClassList.TL_TYPE_USB == interface_info.TLayer_type:
|
||||
interface_info_list.append({
|
||||
'handle' : interface_handle,
|
||||
'type' : GxTLClassList.TL_TYPE_USB,
|
||||
'display_name' : string_decoding( interface_info.IF_info.USB_interface_info.display_name),
|
||||
'interface_id' : string_decoding(interface_info.IF_info.USB_interface_info.interface_id),
|
||||
'serial_number' : string_decoding(interface_info.IF_info.USB_interface_info.serial_number),
|
||||
'description' : string_decoding(interface_info.IF_info.USB_interface_info.description),
|
||||
'init_flag' : 0,
|
||||
'PCIE_info' : 0,
|
||||
'reserved' : array_decoding(interface_info.IF_info.USB_interface_info.reserved),
|
||||
})
|
||||
else:
|
||||
interface_info_list.append({
|
||||
'handle' : 0,
|
||||
'type' : GxTLClassList.TL_TYPE_UNKNOWN,
|
||||
'display_name' : string_decoding(''),
|
||||
'interface_id' : '',
|
||||
'serial_number' : '',
|
||||
'description' : '',
|
||||
'init_flag' : 0,
|
||||
'PCIE_info' : 0,
|
||||
'reserved' : [],
|
||||
})
|
||||
return interface_number,interface_info_list
|
||||
|
||||
|
||||
def __get_ip_info(self, base_info_list, dev_mum):
|
||||
"""
|
||||
:brief Get the network information
|
||||
"""
|
||||
|
||||
ip_info_list = []
|
||||
for i in range(dev_mum):
|
||||
if base_info_list[i].device_class == GxDeviceClassList.GEV:
|
||||
status, ip_info = gx_get_device_ip_info(i + 1)
|
||||
StatusProcessor.process(status, 'DeviceManager', '__get_ip_info')
|
||||
ip_info_list.append(ip_info)
|
||||
else:
|
||||
ip_info_list.append(GxDeviceIPInfo())
|
||||
|
||||
return ip_info_list
|
||||
|
||||
def update_device_list(self, timeout=200):
|
||||
"""
|
||||
:brief enumerate the same network segment devices
|
||||
:param timeout: Enumeration timeout, range:[0, 0xFFFFFFFF]
|
||||
:return: dev_num: device number
|
||||
device_info_list: all device info list
|
||||
"""
|
||||
if not isinstance(timeout, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.update_device_list: "
|
||||
"Expected timeout type is int, not %s" % type(timeout))
|
||||
|
||||
if (timeout < 0) or (timeout > UNSIGNED_INT_MAX):
|
||||
print("DeviceManager.update_device_list: "
|
||||
"timeout out of bounds, timeout: minimum=0, maximum=%s" % hex(UNSIGNED_INT_MAX).__str__())
|
||||
return 0, None
|
||||
|
||||
status, dev_num = gx_update_device_list(timeout)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'update_device_list')
|
||||
|
||||
self.__interface_num, self.__interface_info_list = self.__get_interface_info_list()
|
||||
|
||||
status, base_info_list = gx_get_all_device_base_info(dev_num)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'update_device_list')
|
||||
|
||||
ip_info_list = self.__get_ip_info(base_info_list, dev_num)
|
||||
self.__device_num = dev_num
|
||||
self.__device_info_list = self.__get_device_info_list(base_info_list, ip_info_list, dev_num)
|
||||
|
||||
return self.__device_num, self.__device_info_list
|
||||
|
||||
def update_device_list_ex(self, tl_type, timeout=2000):
|
||||
"""
|
||||
:brief Enumerate the device_type type devices
|
||||
:param tl_type:device type
|
||||
:param timeout: Enumeration timeout, range:[0, 0xFFFFFFFF]
|
||||
:return: dev_num: device number
|
||||
device_info_list: all device info list
|
||||
"""
|
||||
if not isinstance(timeout, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.update_device_list: "
|
||||
"Expected timeout type is int, not %s" % type(timeout))
|
||||
|
||||
if (timeout < 0) or (timeout > UNSIGNED_INT_MAX):
|
||||
print("DeviceManager.update_device_list: "
|
||||
"timeout out of bounds, timeout: minimum=0, maximum=%s" % hex(UNSIGNED_INT_MAX).__str__())
|
||||
return 0, None
|
||||
|
||||
status, dev_num = gx_update_device_list_ex(tl_type, timeout)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'update_device_list_ex')
|
||||
|
||||
self.__interface_num, self.__interface_info_list = self.__get_interface_info_list()
|
||||
|
||||
status, base_info_list = gx_get_all_device_base_info(dev_num)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'update_device_list_ex')
|
||||
|
||||
ip_info_list = self.__get_ip_info(base_info_list, dev_num)
|
||||
self.__device_num = dev_num
|
||||
self.__device_info_list = self.__get_device_info_list(base_info_list, ip_info_list, dev_num)
|
||||
|
||||
return self.__device_num, self.__device_info_list
|
||||
|
||||
def update_all_device_list(self, timeout=200):
|
||||
"""
|
||||
:brief Enumerate devices on different network segments
|
||||
:param timeout: Enumeration timeout, range:[0, 0xFFFFFFFF]
|
||||
:return: dev_num: device number
|
||||
device_info_list: all device info list
|
||||
"""
|
||||
if not isinstance(timeout, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.update_all_device_list: "
|
||||
"Expected timeout type is int, not %s" % type(timeout))
|
||||
|
||||
if (timeout < 0) or (timeout > UNSIGNED_INT_MAX):
|
||||
print("DeviceManager.update_all_device_list: "
|
||||
"timeout out of bounds, timeout: minimum=0, maximum=%s" % hex(UNSIGNED_INT_MAX).__str__())
|
||||
return 0, None
|
||||
|
||||
status, dev_num = gx_update_all_device_list(timeout)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'update_all_device_list')
|
||||
|
||||
self.__interface_num, self.__interface_info_list = self.__get_interface_info_list()
|
||||
|
||||
status, base_info_list = gx_get_all_device_base_info(dev_num)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'update_all_device_list')
|
||||
|
||||
ip_info_list = self.__get_ip_info(base_info_list, dev_num)
|
||||
self.__device_num = dev_num
|
||||
self.__device_info_list = self.__get_device_info_list(base_info_list, ip_info_list, dev_num)
|
||||
|
||||
return self.__device_num, self.__device_info_list
|
||||
|
||||
def get_interface_number(self):
|
||||
"""
|
||||
:brief Get device number
|
||||
:return: device number
|
||||
"""
|
||||
return self.__interface_num
|
||||
|
||||
def get_interface_info(self):
|
||||
"""
|
||||
:brief Get device number
|
||||
:return: device number
|
||||
"""
|
||||
return self.__interface_info_list
|
||||
|
||||
def get_interface(self, index):
|
||||
"""
|
||||
:brief Get device number
|
||||
:return: device number
|
||||
"""
|
||||
if not isinstance(index, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.get_interface: "
|
||||
"Expected index type is int, not %s" % type(index))
|
||||
|
||||
if index < 1:
|
||||
print("DeviceManager.get_interface: index must start from 1")
|
||||
return None
|
||||
elif index > UNSIGNED_INT_MAX:
|
||||
print("DeviceManager.get_interface: index maximum: %s" % hex(UNSIGNED_INT_MAX).__str__())
|
||||
return None
|
||||
|
||||
if self.__interface_num < index:
|
||||
# Re-update the device
|
||||
self.update_device_list()
|
||||
if self.__interface_num < index:
|
||||
raise NotFoundDevice("DeviceManager.get_interface: invalid index")
|
||||
|
||||
status, interface_handle = gx_get_interface_handle(index)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'get_interface')
|
||||
|
||||
return Interface(interface_handle, self.__interface_info_list[ index - 1])
|
||||
|
||||
|
||||
def get_device_number(self):
|
||||
"""
|
||||
:brief Get device number
|
||||
:return: device number
|
||||
"""
|
||||
return self.__device_num
|
||||
|
||||
def get_device_info(self):
|
||||
"""
|
||||
:brief Get all device info
|
||||
:return: info_dict: device info list
|
||||
"""
|
||||
return self.__device_info_list
|
||||
|
||||
def open_device_by_index(self, index, access_mode=GxAccessMode.CONTROL):
|
||||
"""
|
||||
:brief open device by index
|
||||
USB3 device return U3VDevice object
|
||||
USB2 device return U2Device object
|
||||
GEV device return GEVDevice object
|
||||
:param index: device index must start from 1
|
||||
:param access_mode: the access of open device
|
||||
:return: Device object
|
||||
"""
|
||||
if not isinstance(index, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_index: "
|
||||
"Expected index type is int, not %s" % type(index))
|
||||
|
||||
if not isinstance(access_mode, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_index: "
|
||||
"Expected access_mode type is int, not %s" % type(access_mode))
|
||||
|
||||
if index < 1:
|
||||
print("DeviceManager.open_device_by_index: index must start from 1")
|
||||
return None
|
||||
elif index > UNSIGNED_INT_MAX:
|
||||
print("DeviceManager.open_device_by_index: index maximum: %s" % hex(UNSIGNED_INT_MAX).__str__())
|
||||
return None
|
||||
|
||||
access_mode_dict = dict(
|
||||
(name, getattr(GxAccessMode, name)) for name in dir(GxAccessMode) if not name.startswith('__'))
|
||||
if access_mode not in access_mode_dict.values():
|
||||
print("DeviceManager.open_device_by_index: "
|
||||
"access_mode out of bounds, %s" % access_mode_dict.__str__())
|
||||
return None
|
||||
|
||||
if self.__device_num < index:
|
||||
# Re-update the device
|
||||
self.update_device_list()
|
||||
if self.__device_num < index:
|
||||
raise NotFoundDevice("DeviceManager.open_device_by_index: invalid index")
|
||||
|
||||
# open devices by index
|
||||
open_param = GxOpenParam()
|
||||
open_param.content = string_encoding(str(index))
|
||||
open_param.open_mode = GxOpenMode.INDEX
|
||||
open_param.access_mode = access_mode
|
||||
status, handle = gx_open_device(open_param)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'open_device_by_index')
|
||||
|
||||
# get device class
|
||||
device_class = self.__device_info_list[index - 1]["device_class"]
|
||||
|
||||
return self.__create_device(device_class, handle)
|
||||
|
||||
def __get_device_class_by_sn(self, sn):
|
||||
"""
|
||||
:brief: 1.find device by sn in self.__device_info_list
|
||||
2.return different objects according to device class
|
||||
:param sn: device serial number
|
||||
:return: device class
|
||||
"""
|
||||
for index in range(self.__device_num):
|
||||
if self.__device_info_list[index]["sn"] == sn:
|
||||
return self.__device_info_list[index]["device_class"]
|
||||
|
||||
# don't find this id in device base info list
|
||||
return -1
|
||||
|
||||
def open_device_by_sn(self, sn, access_mode=GxAccessMode.CONTROL):
|
||||
"""
|
||||
:brief open device by serial number(SN)
|
||||
USB3 device return U3VDevice object
|
||||
USB2 device return U2Device object
|
||||
GEV device return GEVDevice object
|
||||
:param sn: device serial number, type: str
|
||||
:param access_mode: the mode of open device[GxAccessMode]
|
||||
:return: Device object
|
||||
"""
|
||||
if not isinstance(sn, str):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_sn: "
|
||||
"Expected sn type is str, not %s" % type(sn))
|
||||
|
||||
if not isinstance(access_mode, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_sn: "
|
||||
"Expected access_mode type is int, not %s" % type(access_mode))
|
||||
|
||||
access_mode_dict = dict(
|
||||
(name, getattr(GxAccessMode, name)) for name in dir(GxAccessMode) if not name.startswith('__'))
|
||||
if access_mode not in access_mode_dict.values():
|
||||
print("DeviceManager.open_device_by_sn: "
|
||||
"access_mode out of bounds, %s" % access_mode_dict.__str__())
|
||||
return None
|
||||
|
||||
# get device class from self.__device_info_list
|
||||
device_class = self.__get_device_class_by_sn(sn)
|
||||
if device_class == -1:
|
||||
# Re-update the device
|
||||
self.update_device_list()
|
||||
device_class = self.__get_device_class_by_sn(sn)
|
||||
if device_class == -1:
|
||||
# don't find this sn
|
||||
raise NotFoundDevice("DeviceManager.open_device_by_sn: Not found device")
|
||||
|
||||
# open devices by sn
|
||||
open_param = GxOpenParam()
|
||||
open_param.content = string_encoding(sn)
|
||||
open_param.open_mode = GxOpenMode.SN
|
||||
open_param.access_mode = access_mode
|
||||
status, handle = gx_open_device(open_param)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'open_device_by_sn')
|
||||
|
||||
return self.__create_device(device_class, handle)
|
||||
|
||||
def __get_device_class_by_user_id(self, user_id):
|
||||
"""
|
||||
:brief: 1.find device according to sn in self.__device_info_list
|
||||
2.return different objects according to device class
|
||||
:param user_id: user ID
|
||||
:return: device class
|
||||
"""
|
||||
for index in range(self.__device_num):
|
||||
if self.__device_info_list[index]["user_id"] == user_id:
|
||||
return self.__device_info_list[index]["device_class"]
|
||||
|
||||
# don't find this id in device base info list
|
||||
return -1
|
||||
|
||||
def open_device_by_user_id(self, user_id, access_mode=GxAccessMode.CONTROL):
|
||||
"""
|
||||
:brief open device by user defined name
|
||||
USB3 device return U3VDevice object
|
||||
GEV device return GEVDevice object
|
||||
:param user_id: user defined name, type:str
|
||||
:param access_mode: the mode of open device[GxAccessMode]
|
||||
:return: Device object
|
||||
"""
|
||||
if not isinstance(user_id, str):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_user_id: "
|
||||
"Expected user_id type is str, not %s" % type(user_id))
|
||||
elif user_id.__len__() == 0:
|
||||
raise InvalidParameter("DeviceManager.open_device_by_user_id: Don't support user_id's length is 0")
|
||||
|
||||
if not isinstance(access_mode, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_user_id: "
|
||||
"Expected access_mode type is int, not %s" % type(access_mode))
|
||||
|
||||
access_mode_dict = dict(
|
||||
(name, getattr(GxAccessMode, name)) for name in dir(GxAccessMode) if not name.startswith('__'))
|
||||
if access_mode not in access_mode_dict.values():
|
||||
print("DeviceManager.open_device_by_user_id: access_mode out of bounds, %s" % access_mode_dict.__str__())
|
||||
return None
|
||||
|
||||
# get device class from self.__device_info_list
|
||||
device_class = self.__get_device_class_by_user_id(user_id)
|
||||
if device_class == -1:
|
||||
# Re-update the device
|
||||
self.update_device_list()
|
||||
device_class = self.__get_device_class_by_user_id(user_id)
|
||||
if device_class == -1:
|
||||
# don't find this user_id
|
||||
raise NotFoundDevice("DeviceManager.open_device_by_user_id: Not found device")
|
||||
|
||||
# open device by user_id
|
||||
open_param = GxOpenParam()
|
||||
open_param.content = string_encoding(user_id)
|
||||
open_param.open_mode = GxOpenMode.USER_ID
|
||||
open_param.access_mode = access_mode
|
||||
status, handle = gx_open_device(open_param)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'open_device_by_user_id')
|
||||
|
||||
return self.__create_device(device_class, handle)
|
||||
|
||||
def open_device_by_ip(self, ip, access_mode=GxAccessMode.CONTROL):
|
||||
"""
|
||||
:brief open device by device ip address
|
||||
:param ip: device ip address, type:str
|
||||
:param access_mode: the mode of open device[GxAccessMode]
|
||||
:return: GEVDevice object
|
||||
"""
|
||||
if not isinstance(ip, str):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_ip: "
|
||||
"Expected ip type is str, not %s" % type(ip))
|
||||
|
||||
if not isinstance(access_mode, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_ip: "
|
||||
"Expected access_mode type is int, not %s" % type(access_mode))
|
||||
|
||||
access_mode_dict = dict(
|
||||
(name, getattr(GxAccessMode, name)) for name in dir(GxAccessMode) if not name.startswith('__'))
|
||||
if access_mode not in access_mode_dict.values():
|
||||
print("DeviceManager.open_device_by_ip: access_mode out of bounds, %s" % access_mode_dict.__str__())
|
||||
return None
|
||||
|
||||
# open device by ip
|
||||
open_param = GxOpenParam()
|
||||
open_param.content = string_encoding(ip)
|
||||
open_param.open_mode = GxOpenMode.IP
|
||||
open_param.access_mode = access_mode
|
||||
status, handle = gx_open_device(open_param)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'open_device_by_ip')
|
||||
|
||||
return self.__create_device(GxDeviceClassList.GEV, handle)
|
||||
|
||||
def open_device_by_mac(self, mac, access_mode=GxAccessMode.CONTROL):
|
||||
"""
|
||||
:brief open device by device mac address
|
||||
:param mac: device mac address, type:str
|
||||
:param access_mode: the mode of open device[GxAccessMode]
|
||||
:return: GEVDevice object
|
||||
"""
|
||||
if not isinstance(mac, str):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_mac: "
|
||||
"Expected mac type is str, not %s" % type(mac))
|
||||
|
||||
if not isinstance(access_mode, INT_TYPE):
|
||||
raise ParameterTypeError("DeviceManager.open_device_by_mac: "
|
||||
"Expected access_mode type is int, not %s" % type(access_mode))
|
||||
|
||||
access_mode_dict = dict(
|
||||
(name, getattr(GxAccessMode, name)) for name in dir(GxAccessMode) if not name.startswith('__'))
|
||||
if access_mode not in access_mode_dict.values():
|
||||
print("DeviceManager.open_device_by_mac: access_mode out of bounds, %s" % access_mode_dict.__str__())
|
||||
return None
|
||||
|
||||
# open device by ip
|
||||
open_param = GxOpenParam()
|
||||
open_param.content = string_encoding(mac)
|
||||
open_param.open_mode = GxOpenMode.MAC
|
||||
open_param.access_mode = access_mode
|
||||
status, handle = gx_open_device(open_param)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'open_device_by_mac')
|
||||
|
||||
return self.__create_device(GxDeviceClassList.GEV, handle)
|
||||
|
||||
def gige_reset_device(self, mac_address, reset_device_mode):
|
||||
"""
|
||||
:brief Reconnection/Reset
|
||||
:param mac_address: The MAC address of the device(str)
|
||||
:param reset_device_mode: Reconnection mode, refer to GxResetDeviceModeEntry
|
||||
:return: None
|
||||
"""
|
||||
_InterUtility.check_type(mac_address, str, "mac_address", "DeviceManager", "gige_reset_device")
|
||||
_InterUtility.check_type(reset_device_mode, int, "reset_device_mode", "DeviceManager", "gige_reset_device")
|
||||
status = gx_gige_reset_device(mac_address, reset_device_mode)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'gige_reset_device')
|
||||
|
||||
|
||||
def gige_force_ip(self, mac_address, ip_address, subnet_mask, default_gate_way):
|
||||
"""
|
||||
:brief Execute the Force IP
|
||||
:param mac_address: The MAC address of the device(str)
|
||||
:param ip_address: Reconnection mode, refer to GxResetDeviceModeEntry
|
||||
:param subnet_mask: The MAC address of the device(str)
|
||||
:param default_gate_way: Reconnection mode, refer to GxResetDeviceModeEntry
|
||||
:return: None
|
||||
"""
|
||||
_InterUtility.check_type(mac_address, str, "mac_address", "DeviceManager", "gige_force_ip")
|
||||
_InterUtility.check_type(ip_address, str, "ip_address", "DeviceManager", "gige_force_ip")
|
||||
_InterUtility.check_type(subnet_mask, str, "subnet_mask", "DeviceManager", "gige_force_ip")
|
||||
_InterUtility.check_type(default_gate_way, str, "default_gate_way", "DeviceManager", "gige_force_ip")
|
||||
status = gx_gige_force_ip(mac_address, ip_address, subnet_mask, default_gate_way)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'gige_force_ip')
|
||||
|
||||
def gige_ip_configuration(self, mac_address, ipconfig_flag, ip_address, subnet_mask, default_gateway, user_id):
|
||||
"""
|
||||
:brief Execute the Force IP
|
||||
:param mac_address: The MAC address of the device(str)
|
||||
:param ipconfig_flag: Reconnection mode, refer to GxResetDeviceModeEntry
|
||||
:param ip_address: The MAC address of the device(str)
|
||||
:param subnet_mask: Reconnection mode, refer to GxResetDeviceModeEntry
|
||||
:param default_gateway: The MAC address of the device(str)
|
||||
:param user_id: Reconnection mode, refer to GxResetDeviceModeEntry
|
||||
:return: None
|
||||
"""
|
||||
_InterUtility.check_type(mac_address, str, "mac_address", "DeviceManager", "gige_ip_configuration")
|
||||
_InterUtility.check_type(ipconfig_flag, int, "ipconfig_flag", "DeviceManager", "gige_ip_configuration")
|
||||
_InterUtility.check_type(ip_address, str, "ip_address", "DeviceManager", "gige_ip_configuration")
|
||||
_InterUtility.check_type(subnet_mask, str, "subnet_mask", "DeviceManager", "gige_ip_configuration")
|
||||
_InterUtility.check_type(default_gateway, str, "default_gateway", "DeviceManager", "gige_ip_configuration")
|
||||
_InterUtility.check_type(user_id, str, "user_id", "DeviceManager", "gige_ip_configuration")
|
||||
status = gx_gige_ip_configuration(mac_address, ipconfig_flag, ip_address, subnet_mask, default_gateway, user_id)
|
||||
StatusProcessor.process(status, 'DeviceManager', 'gige_ip_configuration')
|
||||
def create_image_format_convert(self):
|
||||
"""
|
||||
:brief create new convert pointer
|
||||
:return: GxImageFormatConvert
|
||||
"""
|
||||
image_format_convert = ImageFormatConvert()
|
||||
return image_format_convert
|
||||
|
||||
def create_image_process(self):
|
||||
"""
|
||||
:brief create image process
|
||||
:return: GxImageFormatConvert
|
||||
"""
|
||||
image_process = ImageProcess()
|
||||
return image_process
|
||||
|
||||
class _InterUtility:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def check_type(var, var_type, var_name="", class_name="", func_name=""):
|
||||
"""
|
||||
:chief check type
|
||||
"""
|
||||
if not isinstance(var, var_type):
|
||||
if not isinstance(var_type, tuple):
|
||||
raise ParameterTypeError("{} {}: Expected {} type is {}, not {}".format(class_name,
|
||||
func_name, var_name,
|
||||
var_type.__name__,
|
||||
type(var).__name__))
|
||||
else:
|
||||
type_name = ""
|
||||
for i, name in enumerate(var_type):
|
||||
type_name = type_name + name.__name__
|
||||
if i != len(var_type) - 1:
|
||||
type_name = type_name + ", "
|
||||
raise ParameterTypeError("{} {}: Expected {} type is ({}), not {}".format(class_name,
|
||||
func_name, var_name,
|
||||
type_name,
|
||||
type(var).__name__))
|
||||
|
||||
@staticmethod
|
||||
def get_pixel_color_filter(pixel_format):
|
||||
"""
|
||||
:brief Calculate pixel color filter based on pixel format
|
||||
:param pixel_format
|
||||
:return: pixel color filter
|
||||
"""
|
||||
gr_tup = (GxPixelFormatEntry.BAYER_GR8, GxPixelFormatEntry.BAYER_GR10,
|
||||
GxPixelFormatEntry.BAYER_GR12, GxPixelFormatEntry.BAYER_GR16)
|
||||
rg_tup = (GxPixelFormatEntry.BAYER_RG8, GxPixelFormatEntry.BAYER_RG10,
|
||||
GxPixelFormatEntry.BAYER_RG12, GxPixelFormatEntry.BAYER_RG16)
|
||||
gb_tup = (GxPixelFormatEntry.BAYER_GB8, GxPixelFormatEntry.BAYER_GB10,
|
||||
GxPixelFormatEntry.BAYER_GB12, GxPixelFormatEntry.BAYER_GB16)
|
||||
bg_tup = (GxPixelFormatEntry.BAYER_BG8, GxPixelFormatEntry.BAYER_BG10,
|
||||
GxPixelFormatEntry.BAYER_BG12, GxPixelFormatEntry.BAYER_BG16)
|
||||
mono_tup = (GxPixelFormatEntry.MONO8, GxPixelFormatEntry.MONO8_SIGNED,
|
||||
GxPixelFormatEntry.MONO10, GxPixelFormatEntry.MONO12,
|
||||
GxPixelFormatEntry.MONO14, GxPixelFormatEntry.MONO16)
|
||||
|
||||
if pixel_format in gr_tup:
|
||||
return DxPixelColorFilter.GR
|
||||
elif pixel_format in rg_tup:
|
||||
return DxPixelColorFilter.RG
|
||||
elif pixel_format in gb_tup:
|
||||
return DxPixelColorFilter.GB
|
||||
elif pixel_format in bg_tup:
|
||||
return DxPixelColorFilter.BG
|
||||
elif pixel_format in mono_tup:
|
||||
return DxPixelColorFilter.NONE
|
||||
else:
|
||||
return -1
|
||||
|
||||
@staticmethod
|
||||
def get_bit_depth(pixel_format):
|
||||
"""
|
||||
:brief Calculate pixel depth based on pixel format
|
||||
:param pixel_format
|
||||
:return: pixel depth
|
||||
"""
|
||||
bpp10_tup = (GxPixelFormatEntry.MONO10, GxPixelFormatEntry.BAYER_GR10, GxPixelFormatEntry.BAYER_RG10,
|
||||
GxPixelFormatEntry.BAYER_GB10, GxPixelFormatEntry.BAYER_BG10)
|
||||
|
||||
bpp12_tup = (GxPixelFormatEntry.MONO12, GxPixelFormatEntry.BAYER_GR12, GxPixelFormatEntry.BAYER_RG12,
|
||||
GxPixelFormatEntry.BAYER_GB12, GxPixelFormatEntry.BAYER_BG12)
|
||||
|
||||
bpp16_tup = (GxPixelFormatEntry.MONO16, GxPixelFormatEntry.BAYER_GR16, GxPixelFormatEntry.BAYER_RG16,
|
||||
GxPixelFormatEntry.BAYER_GB16, GxPixelFormatEntry.BAYER_BG16)
|
||||
|
||||
if (pixel_format & PIXEL_BIT_MASK) == GX_PIXEL_8BIT:
|
||||
return GxPixelSizeEntry.BPP8
|
||||
elif pixel_format in bpp10_tup:
|
||||
return GxPixelSizeEntry.BPP10
|
||||
elif pixel_format in bpp12_tup:
|
||||
return GxPixelSizeEntry.BPP12
|
||||
elif pixel_format == GxPixelFormatEntry.MONO14:
|
||||
return GxPixelSizeEntry.BPP14
|
||||
elif pixel_format in bpp16_tup:
|
||||
return GxPixelSizeEntry.BPP16
|
||||
elif (pixel_format & PIXEL_BIT_MASK) == GX_PIXEL_24BIT:
|
||||
return GxPixelSizeEntry.BPP24
|
||||
elif (pixel_format & PIXEL_BIT_MASK) == GX_PIXEL_48BIT:
|
||||
return GxPixelSizeEntry.BPP48
|
||||
else:
|
||||
return -1
|
||||
|
||||
|
@ -0,0 +1,198 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .gxiapi import *
|
||||
import types
|
||||
|
||||
class UnexpectedError(Exception):
|
||||
"""
|
||||
brief: Unexpected error exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class NotFoundTL(Exception):
|
||||
"""
|
||||
brief: not found TL exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class NotFoundDevice(Exception):
|
||||
"""
|
||||
brief: not found device exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class OffLine(Exception):
|
||||
"""
|
||||
brief: device offline exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class InvalidParameter(Exception):
|
||||
"""
|
||||
brief: input invalid parameter exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class InvalidHandle(Exception):
|
||||
"""
|
||||
brief: invalid handle exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class InvalidCall(Exception):
|
||||
"""
|
||||
brief: invalid callback exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class InvalidAccess(Exception):
|
||||
"""
|
||||
brief: invalid access exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class NeedMoreBuffer(Exception):
|
||||
"""
|
||||
brief: need more buffer exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class FeatureTypeError(Exception):
|
||||
"""
|
||||
brief: feature id error exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class OutOfRange(Exception):
|
||||
"""
|
||||
brief: param out of range exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
class NoImplemented(Exception):
|
||||
"""
|
||||
brief: param out of Implemented exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class NotInitApi(Exception):
|
||||
"""
|
||||
brief: not init api exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class Timeout(Exception):
|
||||
"""
|
||||
brief: timeout exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
class ParameterTypeError(Exception):
|
||||
"""
|
||||
brief: parameter type error exception
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
def __init__(self, args):
|
||||
Exception.__init__(self, args)
|
||||
|
||||
|
||||
def exception_deal(status, args):
|
||||
"""
|
||||
brief: deal with different exception
|
||||
param: status function return value
|
||||
param: args exception description
|
||||
return: none
|
||||
"""
|
||||
if status == GxStatusList.ERROR:
|
||||
raise UnexpectedError(args)
|
||||
elif status == GxStatusList.NOT_FOUND_TL:
|
||||
raise NotFoundTL(args)
|
||||
elif status == GxStatusList.NOT_FOUND_DEVICE:
|
||||
raise NotFoundDevice(args)
|
||||
elif status == GxStatusList.OFFLINE:
|
||||
raise OffLine(args)
|
||||
elif status == GxStatusList.INVALID_PARAMETER:
|
||||
raise InvalidParameter(args)
|
||||
elif status == GxStatusList.INVALID_HANDLE:
|
||||
raise InvalidHandle(args)
|
||||
elif status == GxStatusList.INVALID_CALL:
|
||||
raise InvalidCall(args)
|
||||
elif status == GxStatusList.INVALID_ACCESS:
|
||||
raise InvalidAccess(args)
|
||||
elif status == GxStatusList.NEED_MORE_BUFFER:
|
||||
raise NeedMoreBuffer(args)
|
||||
elif status == GxStatusList.ERROR_TYPE:
|
||||
raise FeatureTypeError(args)
|
||||
elif status == GxStatusList.OUT_OF_RANGE:
|
||||
raise OutOfRange(args)
|
||||
elif status == GxStatusList.NOT_IMPLEMENTED:
|
||||
raise NoImplemented(args)
|
||||
elif status == GxStatusList.NOT_INIT_API:
|
||||
raise NotInitApi(args)
|
||||
elif status == GxStatusList.TIMEOUT:
|
||||
raise Timeout(args)
|
||||
elif status == GxStatusList.REPEAT_OPENED:
|
||||
raise InvalidAccess(args)
|
||||
else:
|
||||
raise Exception(args)
|
@ -0,0 +1,515 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
#以下已废弃,请使用上面的类型
|
||||
|
||||
from .gxiapi import *
|
||||
from .ImageProc import *
|
||||
from .StatusProcessor import *
|
||||
|
||||
if sys.version_info.major > 2:
|
||||
INT_TYPE = int
|
||||
else:
|
||||
INT_TYPE = (int, long)
|
||||
|
||||
class Feature:
|
||||
def __init__(self, handle, feature):
|
||||
"""
|
||||
:param handle: The handle of the device
|
||||
:param feature: The feature code ID
|
||||
"""
|
||||
self.__handle = handle
|
||||
self.__feature = feature
|
||||
self.feature_name = self.get_name()
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
brief: Getting Feature Name
|
||||
return: Success: feature name
|
||||
Failed: convert feature ID to string
|
||||
"""
|
||||
status, name = gx_get_feature_name(self.__handle, self.__feature)
|
||||
if status != GxStatusList.SUCCESS:
|
||||
name = (hex(self.__feature)).__str__()
|
||||
|
||||
return name
|
||||
|
||||
def is_implemented(self):
|
||||
"""
|
||||
brief: Determining whether the feature is implemented
|
||||
return: is_implemented
|
||||
"""
|
||||
status, is_implemented = gx_is_implemented(self.__handle, self.__feature)
|
||||
if status == GxStatusList.SUCCESS:
|
||||
return is_implemented
|
||||
elif status == GxStatusList.INVALID_PARAMETER:
|
||||
return False
|
||||
else:
|
||||
StatusProcessor.process(status, 'Feature', 'is_implemented')
|
||||
|
||||
def is_readable(self):
|
||||
"""
|
||||
brief: Determining whether the feature is readable
|
||||
return: is_readable
|
||||
"""
|
||||
implemented = self.is_implemented()
|
||||
if not implemented:
|
||||
return False
|
||||
|
||||
status, is_readable = gx_is_readable(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'Feature', 'is_readable')
|
||||
return is_readable
|
||||
|
||||
def is_writable(self):
|
||||
"""
|
||||
brief: Determining whether the feature is writable
|
||||
return: is_writable
|
||||
"""
|
||||
implemented = self.is_implemented()
|
||||
if not implemented:
|
||||
return False
|
||||
|
||||
status, is_writable = gx_is_writable(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'Feature', 'is_writable')
|
||||
return is_writable
|
||||
|
||||
|
||||
class IntFeature(Feature):
|
||||
def __init__(self, handle, feature):
|
||||
"""
|
||||
:param handle: The handle of the device
|
||||
:param feature: The feature code ID
|
||||
"""
|
||||
Feature.__init__(self, handle, feature)
|
||||
self.__handle = handle
|
||||
self.__feature = feature
|
||||
|
||||
def __range_dict(self, int_range):
|
||||
"""
|
||||
:brief Convert GxIntRange to dictionary
|
||||
:param int_range: GxIntRange
|
||||
:return: range_dicts
|
||||
"""
|
||||
range_dicts = {
|
||||
"min": int_range.min,
|
||||
"max": int_range.max,
|
||||
"inc": int_range.inc
|
||||
}
|
||||
return range_dicts
|
||||
|
||||
def get_range(self):
|
||||
"""
|
||||
:brief Getting integer range
|
||||
:return: integer range dictionary
|
||||
"""
|
||||
implemented = self.is_implemented()
|
||||
if not implemented:
|
||||
#print("%s.get_range is not support" % self.feature_name)
|
||||
raise NoImplemented("%s.get_range is not support" % self.feature_name)
|
||||
|
||||
status, int_range = gx_get_int_range(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'IntFeature', 'get_range')
|
||||
return self.__range_dict(int_range)
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting integer value
|
||||
:return: integer value
|
||||
"""
|
||||
readable = self.is_readable()
|
||||
if not readable:
|
||||
#print("%s.get is not readable" % self.feature_name)
|
||||
raise InvalidAccess("%s.get is not readable" % self.feature_name)
|
||||
|
||||
status, int_value = gx_get_int(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'IntFeature', 'get')
|
||||
return int_value
|
||||
|
||||
def set(self, int_value):
|
||||
"""
|
||||
:brief Setting integer value
|
||||
:param int_value
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(int_value, INT_TYPE):
|
||||
raise ParameterTypeError("IntFeature.set: "
|
||||
"Expected int_value type is int, not %s" % type(int_value))
|
||||
|
||||
writeable = self.is_writable()
|
||||
if not writeable:
|
||||
#print("%s.set: is not writeable" % self.feature_name)
|
||||
raise InvalidAccess("%s.set: is not writeable" % self.feature_name)
|
||||
|
||||
int_range = self.get_range()
|
||||
check_ret = range_check(int_value, int_range["min"], int_range["max"], int_range["inc"])
|
||||
if not check_ret:
|
||||
#print("IntFeature.set: "
|
||||
# "int_value out of bounds, %s.range=[%d, %d, %d]" %
|
||||
# (self.feature_name, int_range["min"], int_range["max"], int_range["inc"]))
|
||||
raise OutOfRange("IntFeature.set: "
|
||||
"int_value out of bounds, %s.range=[%d, %d, %d]" %
|
||||
(self.feature_name, int_range["min"], int_range["max"], int_range["inc"]))
|
||||
return
|
||||
|
||||
status = gx_set_int(self.__handle, self.__feature, int_value)
|
||||
StatusProcessor.process(status, 'IntFeature', 'set')
|
||||
|
||||
|
||||
class FloatFeature(Feature):
|
||||
def __init__(self, handle, feature):
|
||||
"""
|
||||
:param handle: The handle of the device
|
||||
:param feature: The feature code ID
|
||||
"""
|
||||
Feature.__init__(self, handle, feature)
|
||||
self.__handle = handle
|
||||
self.__feature = feature
|
||||
|
||||
def __range_dict(self, float_range):
|
||||
"""
|
||||
:brief Convert GxFloatRange to dictionary
|
||||
:param float_range: GxFloatRange
|
||||
:return: range_dicts
|
||||
"""
|
||||
range_dicts = {
|
||||
"min": float_range.min,
|
||||
"max": float_range.max,
|
||||
"inc": float_range.inc,
|
||||
"unit": string_decoding(float_range.unit),
|
||||
"inc_is_valid": float_range.inc_is_valid
|
||||
}
|
||||
return range_dicts
|
||||
|
||||
def get_range(self):
|
||||
"""
|
||||
:brief Getting float range
|
||||
:return: float range dictionary
|
||||
"""
|
||||
implemented = self.is_implemented()
|
||||
if not implemented:
|
||||
#print("%s.get_range is not support" % self.feature_name)
|
||||
raise NoImplemented("%s.get_range is not support" % self.feature_name)
|
||||
|
||||
status, float_range = gx_get_float_range(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'FloatFeature', 'get_range')
|
||||
return self.__range_dict(float_range)
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting float value
|
||||
:return: float value
|
||||
"""
|
||||
readable = self.is_readable()
|
||||
if not readable:
|
||||
#print("%s.get: is not readable" % self.feature_name)
|
||||
raise InvalidAccess("%s.get: is not readable" % self.feature_name)
|
||||
|
||||
status, float_value = gx_get_float(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'FloatFeature', 'get')
|
||||
return float_value
|
||||
|
||||
def set(self, float_value):
|
||||
"""
|
||||
:brief Setting float value
|
||||
:param float_value
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(float_value, (INT_TYPE, float)):
|
||||
raise ParameterTypeError("FloatFeature.set: "
|
||||
"Expected float_value type is float, not %s" % type(float_value))
|
||||
|
||||
writeable = self.is_writable()
|
||||
if not writeable:
|
||||
#print("%s.set: is not writeable" % self.feature_name)
|
||||
raise InvalidAccess("%s.set: is not writeable" % self.feature_name)
|
||||
|
||||
float_range = self.get_range()
|
||||
check_ret = range_check(float_value, float_range["min"], float_range["max"])
|
||||
if not check_ret:
|
||||
#print("FloatFeature.set: float_value out of bounds, %s.range=[%f, %f]" %
|
||||
# (self.feature_name, float_range["min"], float_range["max"]))
|
||||
raise OutOfRange("FloatFeature.set: float_value out of bounds, %s.range=[%f, %f]" %
|
||||
(self.feature_name, float_range["min"], float_range["max"]))
|
||||
return
|
||||
|
||||
status = gx_set_float(self.__handle, self.__feature, float_value)
|
||||
StatusProcessor.process(status, 'FloatFeature', 'set')
|
||||
|
||||
|
||||
class EnumFeature(Feature):
|
||||
def __init__(self, handle, feature):
|
||||
"""
|
||||
:param handle: The handle of the device
|
||||
:param feature: The feature code ID
|
||||
"""
|
||||
Feature.__init__(self, handle, feature)
|
||||
self.__handle = handle
|
||||
self.__feature = feature
|
||||
|
||||
def get_range(self):
|
||||
"""
|
||||
:brief Getting range of Enum feature
|
||||
:return: enum_dict: enum range dictionary
|
||||
"""
|
||||
implemented = self.is_implemented()
|
||||
if not implemented:
|
||||
#print("%s.get_range: is not support" % self.feature_name)
|
||||
raise NoImplemented("%s.get_range: is not support" % self.feature_name)
|
||||
|
||||
status, enum_num = gx_get_enum_entry_nums(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'EnumFeature', 'get_range')
|
||||
|
||||
status, enum_list = gx_get_enum_description(self.__handle, self.__feature, enum_num)
|
||||
StatusProcessor.process(status, 'EnumFeature', 'get_range')
|
||||
|
||||
enum_dict = {}
|
||||
for i in range(enum_num):
|
||||
enum_dict[string_decoding(enum_list[i].symbolic)] = enum_list[i].value
|
||||
|
||||
return enum_dict
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting value of Enum feature
|
||||
:return: enum_value: enum value
|
||||
enum_str: string for enum description
|
||||
"""
|
||||
readable = self.is_readable()
|
||||
if not readable:
|
||||
#print("%s.get: is not readable" % self.feature_name)
|
||||
raise InvalidAccess("%s.get: is not readable" % self.feature_name)
|
||||
|
||||
status, enum_value = gx_get_enum(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'EnumFeature', 'get')
|
||||
|
||||
range_dict = self.get_range()
|
||||
new_dicts = {v: k for k, v in range_dict.items()}
|
||||
return enum_value, new_dicts[enum_value]
|
||||
|
||||
def set(self, enum_value):
|
||||
"""
|
||||
:brief Setting enum value
|
||||
:param enum_value
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(enum_value, INT_TYPE):
|
||||
raise ParameterTypeError("EnumFeature.set: "
|
||||
"Expected enum_value type is int, not %s" % type(enum_value))
|
||||
|
||||
writeable = self.is_writable()
|
||||
if not writeable:
|
||||
#print("%s.set: is not writeable" % self.feature_name)
|
||||
raise InvalidAccess("%s.set: is not writeable" % self.feature_name)
|
||||
|
||||
range_dict = self.get_range()
|
||||
enum_value_list = range_dict.values()
|
||||
if enum_value not in enum_value_list:
|
||||
#print("EnumFeature.set: enum_value out of bounds, %s.range:%s" %
|
||||
# (self.feature_name, range_dict.__str__()))
|
||||
raise OutOfRange("EnumFeature.set: enum_value out of bounds, %s.range:%s" %
|
||||
(self.feature_name, range_dict.__str__()))
|
||||
return
|
||||
|
||||
status = gx_set_enum(self.__handle, self.__feature, enum_value)
|
||||
StatusProcessor.process(status, 'EnumFeature', 'set')
|
||||
|
||||
|
||||
class BoolFeature(Feature):
|
||||
def __init__(self, handle, feature):
|
||||
"""
|
||||
:param handle: The handle of the device
|
||||
:param feature: The feature code ID
|
||||
"""
|
||||
Feature.__init__(self, handle, feature)
|
||||
self.__handle = handle
|
||||
self.__feature = feature
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting bool value
|
||||
:return: bool value[bool]
|
||||
"""
|
||||
readable = self.is_readable()
|
||||
if not readable:
|
||||
# print("%s.get is not readable" % self.feature_name)
|
||||
raise InvalidAccess("%s.get is not readable" % self.feature_name)
|
||||
|
||||
status, bool_value = gx_get_bool(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'BoolFeature', 'get')
|
||||
return bool_value
|
||||
|
||||
def set(self, bool_value):
|
||||
"""
|
||||
:brief Setting bool value
|
||||
:param bool_value[bool]
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(bool_value, bool):
|
||||
raise ParameterTypeError("BoolFeature.set: "
|
||||
"Expected bool_value type is bool, not %s" % type(bool_value))
|
||||
|
||||
writeable = self.is_writable()
|
||||
if not writeable:
|
||||
#print("%s.set: is not writeable" % self.feature_name)
|
||||
raise InvalidAccess("%s.set: is not writeable" % self.feature_name)
|
||||
|
||||
status = gx_set_bool(self.__handle, self.__feature, bool_value)
|
||||
StatusProcessor.process(status, 'BoolFeature', 'set')
|
||||
|
||||
|
||||
class StringFeature(Feature):
|
||||
def __init__(self, handle, feature):
|
||||
"""
|
||||
:param handle: The handle of the device
|
||||
:param feature: The feature code ID
|
||||
"""
|
||||
Feature.__init__(self, handle, feature)
|
||||
self.__handle = handle
|
||||
self.__feature = feature
|
||||
|
||||
def get_string_max_length(self):
|
||||
"""
|
||||
:brief Getting the maximum length that string can set
|
||||
:return: length: the maximum length that string can set
|
||||
"""
|
||||
implemented = self.is_implemented()
|
||||
if not implemented:
|
||||
#print("%s.get_string_max_length is not support" % self.feature_name)
|
||||
raise NoImplemented("%s.get_string_max_length is not support" % self.feature_name)
|
||||
|
||||
status, length = gx_get_string_max_length(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'StringFeature', 'get_string_max_length')
|
||||
return length
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting string value
|
||||
:return: strings
|
||||
"""
|
||||
readable = self.is_readable()
|
||||
if not readable:
|
||||
#print("%s.get is not readable" % self.feature_name)
|
||||
raise InvalidAccess("%s.get is not readable" % self.feature_name)
|
||||
|
||||
status, strings = gx_get_string(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'StringFeature', 'get')
|
||||
return strings
|
||||
|
||||
def set(self, input_string):
|
||||
"""
|
||||
:brief Setting string value
|
||||
:param input_string[string]
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(input_string, str):
|
||||
raise ParameterTypeError("StringFeature.set: "
|
||||
"Expected input_string type is str, not %s" % type(input_string))
|
||||
|
||||
writeable = self.is_writable()
|
||||
if not writeable:
|
||||
#print("%s.set: is not writeable" % self.feature_name)
|
||||
raise InvalidAccess("%s.set: is not writeable" % self.feature_name)
|
||||
|
||||
max_length = self.get_string_max_length()
|
||||
if input_string.__len__() > max_length:
|
||||
#print("StringFeature.set: " "input_string length out of bounds, %s.length_max:%s" % (self.feature_name, max_length))
|
||||
raise OutOfRange("StringFeature.set: "
|
||||
"input_string length out of bounds, %s.length_max:%s"
|
||||
% (self.feature_name, max_length))
|
||||
return
|
||||
|
||||
status = gx_set_string(self.__handle, self.__feature, input_string)
|
||||
StatusProcessor.process(status, 'StringFeature', 'set')
|
||||
|
||||
|
||||
class BufferFeature(Feature):
|
||||
def __init__(self, handle, feature):
|
||||
"""
|
||||
:param handle: The handle of the device
|
||||
:param feature: The feature code ID
|
||||
"""
|
||||
Feature.__init__(self, handle, feature)
|
||||
self.__handle = handle
|
||||
self.__feature = feature
|
||||
|
||||
def get_buffer_length(self):
|
||||
"""
|
||||
:brief Getting buffer length
|
||||
:return: length: buffer length
|
||||
"""
|
||||
implemented = self.is_implemented()
|
||||
if not implemented:
|
||||
#print("%s.get_buffer_length is not support" % self.feature_name)
|
||||
raise NoImplemented("%s.get_buffer_length is not support" % self.feature_name)
|
||||
|
||||
status, length = gx_get_buffer_length(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'BuffFeature', 'get_buffer_length')
|
||||
return length
|
||||
|
||||
def get_buffer(self):
|
||||
"""
|
||||
:brief Getting buffer data
|
||||
:return: Buffer object
|
||||
|
||||
"""
|
||||
readable = self.is_readable()
|
||||
if not readable:
|
||||
#print("%s.get_buffer is not readable" % self.feature_name)
|
||||
raise InvalidAccess("%s.get_buffer is not readable" % self.feature_name)
|
||||
|
||||
status, buf = gx_get_buffer(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'BuffFeature', 'get_buffer')
|
||||
return Buffer(buf)
|
||||
|
||||
def set_buffer(self, buf):
|
||||
"""
|
||||
:brief Setting buffer data
|
||||
:param buf: Buffer object
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(buf, Buffer):
|
||||
raise ParameterTypeError("BuffFeature.set_buffer: "
|
||||
"Expected buff type is Buffer, not %s" % type(buf))
|
||||
|
||||
writeable = self.is_writable()
|
||||
if not writeable:
|
||||
#print("%s.set_buffer is not writeable" % self.feature_name)
|
||||
raise InvalidAccess("%s.set_buffer is not writeable" % self.feature_name)
|
||||
|
||||
max_length = self.get_buffer_length()
|
||||
if buf.get_length() > max_length:
|
||||
#print("BuffFeature.set_buffer: "
|
||||
# "buff length out of bounds, %s.length_max:%s" % (self.feature_name, max_length))
|
||||
raise OutOfRange("BuffFeature.set_buffer: "
|
||||
"buff length out of bounds, %s.length_max:%s" % (self.feature_name, max_length))
|
||||
return
|
||||
|
||||
status = gx_set_buffer(self.__handle, self.__feature,
|
||||
buf.get_ctype_array(), buf.get_length())
|
||||
StatusProcessor.process(status, 'BuffFeature', 'set_buffer')
|
||||
|
||||
|
||||
class CommandFeature(Feature):
|
||||
def __init__(self, handle, feature):
|
||||
"""
|
||||
:param handle: The handle of the device
|
||||
:param feature: The feature code ID
|
||||
"""
|
||||
Feature.__init__(self, handle, feature)
|
||||
self.__handle = handle
|
||||
self.__feature = feature
|
||||
|
||||
def send_command(self):
|
||||
"""
|
||||
:brief Sending command
|
||||
:return: None
|
||||
"""
|
||||
implemented = self.is_implemented()
|
||||
if not implemented:
|
||||
#print("%s.send_command is not support" % self.feature_name)
|
||||
raise NoImplemented("%s.send_command is not support" % self.feature_name)
|
||||
|
||||
status = gx_send_command(self.__handle, self.__feature)
|
||||
StatusProcessor.process(status, 'CommandFeature', 'send_command')
|
||||
|
@ -0,0 +1,273 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .Feature_s import *
|
||||
from .StatusProcessor import *
|
||||
import types
|
||||
|
||||
class FeatureControl:
|
||||
def __init__(self,handle):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle:
|
||||
"""
|
||||
self.__handle = handle
|
||||
|
||||
def is_implemented(self,feature_name):
|
||||
"""
|
||||
:brief Get feature node is implemented
|
||||
:param feature_name: Feature node name
|
||||
:return: Is implemented
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.is_implemented: "
|
||||
"Expected feature_name type is int, not %s" % type(feature_name))
|
||||
|
||||
status, node_access = gx_get_node_access_mode( self.__handle ,feature_name)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'is_implemented')
|
||||
if ((node_access == GxNodeAccessMode.MODE_NI) or (node_access == GxNodeAccessMode.MODE_UNDEF)):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def is_readable(self, feature_name):
|
||||
"""
|
||||
brief: Determining whether the feature is readable
|
||||
return: is_readable
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_int_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
status, node_access = gx_get_node_access_mode( self.__handle ,feature_name)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'is_readable')
|
||||
if ((node_access == GxNodeAccessMode.MODE_RO) or (node_access == GxNodeAccessMode.MODE_RW)):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_writable(self, feature_name):
|
||||
"""
|
||||
brief: Determining whether the feature is writable
|
||||
return: is_writable
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_int_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
status, node_access = gx_get_node_access_mode( self.__handle ,feature_name)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'is_readable')
|
||||
if ((node_access == GxNodeAccessMode.MODE_WO) or (node_access == GxNodeAccessMode.MODE_RW)):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_int_feature(self, feature_name):
|
||||
"""
|
||||
:brief Get int type feature object
|
||||
:param feature_name: Feature node name
|
||||
:return: Int type feature object
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_int_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
if not self.is_implemented( feature_name):
|
||||
raise UnexpectedError( "FeatureControl.get_int_feature: "
|
||||
"The feature '%s' is not implemented" %feature_name)
|
||||
|
||||
int_feature = IntFeature_s( self.__handle, feature_name)
|
||||
return int_feature
|
||||
|
||||
def get_enum_feature(self, feature_name):
|
||||
"""
|
||||
:brief Get enum type feature object
|
||||
:param feature_name: Feature node name
|
||||
:return: Enum type feature object
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_enum_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
if not self.is_implemented( feature_name):
|
||||
raise UnexpectedError( "FeatureControl.get_enum_feature: "
|
||||
"The feature '%s' is not implemented" %feature_name)
|
||||
|
||||
enum_feature = EnumFeature_s( self.__handle, feature_name)
|
||||
return enum_feature
|
||||
|
||||
def get_float_feature(self, feature_name):
|
||||
"""
|
||||
:brief Get float type feature object
|
||||
:param feature_name: Feature node name
|
||||
:return: Float type feature object
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_float_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
if not self.is_implemented( feature_name):
|
||||
raise UnexpectedError( "FeatureControl.get_float_feature: "
|
||||
"The feature '%s' is not implemented" %feature_name)
|
||||
|
||||
float_feature = FloatFeature_s( self.__handle, feature_name)
|
||||
return float_feature
|
||||
|
||||
def get_bool_feature(self, feature_name):
|
||||
"""
|
||||
:brief Get bool type feature object
|
||||
:param feature_name: Feature node name
|
||||
:return: Bool type feature object
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_bool_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
if not self.is_implemented( feature_name):
|
||||
raise UnexpectedError( "FeatureControl.get_bool_feature: "
|
||||
"The feature '%s' is not implemented" %feature_name)
|
||||
|
||||
bool_feature = BoolFeature_s( self.__handle, feature_name)
|
||||
return bool_feature
|
||||
|
||||
def get_string_feature(self, feature_name):
|
||||
"""
|
||||
:brief Get string type feature object
|
||||
:param feature_name: Feature node name
|
||||
:return: String type feature object
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_string_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
if not self.is_implemented( feature_name):
|
||||
raise UnexpectedError( "FeatureControl.get_string_feature: "
|
||||
"The feature '%s' is not implemented" %feature_name)
|
||||
|
||||
string_feature = StringFeature_s( self.__handle, feature_name)
|
||||
return string_feature
|
||||
|
||||
def get_command_feature(self, feature_name):
|
||||
"""
|
||||
:brief Get command type feature object
|
||||
:param feature_name: Feature node name
|
||||
:return: Command type feature object
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_command_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
if not self.is_implemented( feature_name):
|
||||
raise UnexpectedError( "FeatureControl.get_command_feature: "
|
||||
"The feature '%s' is not implemented" %feature_name)
|
||||
|
||||
command_feature = CommandFeature_s( self.__handle, feature_name)
|
||||
return command_feature
|
||||
|
||||
def get_register_feature(self, feature_name):
|
||||
"""
|
||||
:brief Get register type feature object
|
||||
:param feature_name: Feature node name
|
||||
:return: Register type feature object
|
||||
"""
|
||||
if not isinstance(feature_name, str):
|
||||
raise ParameterTypeError("FeatureControl.get_register_feature: "
|
||||
"Expected feature_name type is str, not %s" % type(feature_name))
|
||||
|
||||
if not self.is_implemented( feature_name):
|
||||
raise UnexpectedError( "FeatureControl.get_register_feature: "
|
||||
"The feature '%s' is not implemented" %feature_name)
|
||||
|
||||
register_feature = RegisterFeature_s( self.__handle, feature_name)
|
||||
return register_feature
|
||||
|
||||
def feature_save(self, file_path):
|
||||
"""
|
||||
:brief Save User Parameter Group
|
||||
:param file_path: Save Parameter file path
|
||||
:return: None
|
||||
"""
|
||||
status = gx_feature_save( self.__handle, file_path)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'feature_save')
|
||||
|
||||
def feature_load(self, file_path, verify=False):
|
||||
"""
|
||||
:brief Load User Parameter Group
|
||||
:param file_path: Load Parameter file path
|
||||
:return: None
|
||||
"""
|
||||
status = gx_feature_load(self.__handle, file_path, verify)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'feature_load')
|
||||
|
||||
def read_port(self, address, size):
|
||||
"""
|
||||
:brief Read register
|
||||
:param address: The address of the register to be read.(type: int)
|
||||
:param bytearray: The data to be read from user.(type: buffer)
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(address, INT_TYPE):
|
||||
raise ParameterTypeError("Device.read_port: "
|
||||
"Expected address type is int, not %s" % type(address))
|
||||
|
||||
if not isinstance(size, INT_TYPE):
|
||||
raise ParameterTypeError("Device.read_port: "
|
||||
"Expected size type is int, not %s" % type(size))
|
||||
|
||||
status, buff_value = gx_read_port( self.__handle, address, size)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'read_port')
|
||||
return buff_value
|
||||
|
||||
def write_port(self, address, buff, size):
|
||||
"""
|
||||
:brief Write register
|
||||
:param address: The address of the register to be written.(type: int)
|
||||
:param bytearray: The data to be written from user.(type: buffer)
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(address, INT_TYPE):
|
||||
raise ParameterTypeError("Device.write_remote_device_port: "
|
||||
"Expected address type is int, not %s" % type(address))
|
||||
|
||||
status = gx_writer_port( self.__handle, address, buff, size)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'write_port')
|
||||
|
||||
def read_port_stacked(self, entries, size):
|
||||
"""
|
||||
:brief Batch read the value of a user-specified register (only for registers with a command value of 4 bytes in length)
|
||||
:entries [in]Batch read register addresses and values
|
||||
[out]Read the data to the corresponding register
|
||||
:read_num [in]Read the number of device registers
|
||||
[out]The number of registers that were successfully read
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(size, INT_TYPE):
|
||||
raise ParameterTypeError("Device.set_read_remote_device_port_stacked: "
|
||||
"Expected size type is int, not %s" % type(size))
|
||||
|
||||
status = gx_read_port_stacked(self.__handle, entries, size)
|
||||
StatusProcessor.process(status, 'Device', 'read_remote_device_port_stacked')
|
||||
|
||||
return status
|
||||
|
||||
def write_port_stacked(self, entries, size):
|
||||
"""
|
||||
:brief Batch read the value of a user-specified register (only for registers with a command value of 4 bytes in length)
|
||||
:entries [in]The address and value of the batch write register
|
||||
:read_num [in]Sets the number of device registers
|
||||
[out]The number of registers that were successfully written
|
||||
:return: none
|
||||
"""
|
||||
if not isinstance(size, INT_TYPE):
|
||||
raise ParameterTypeError("Device.set_read_remote_device_port_stacked: "
|
||||
"Expected size type is int, not %s" % type(size))
|
||||
|
||||
status = gx_set_write_remote_device_port_stacked(self.__handle, entries, size)
|
||||
StatusProcessor.process(status, 'Device', 'set_write_remote_device_port_stacked')
|
||||
|
||||
return status
|
@ -0,0 +1,347 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .ImageProc import *
|
||||
from .gxiapi import *
|
||||
from .StatusProcessor import *
|
||||
import types
|
||||
|
||||
if sys.version_info.major > 2:
|
||||
INT_TYPE = int
|
||||
else:
|
||||
INT_TYPE = (int, long)
|
||||
|
||||
class Feature_s:
|
||||
def __init__(self, handle, feature_name):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface featrue control handle\Device local layer feature control\Device remote layer featrure control\Device stream layer feature control
|
||||
:param feature_name: Feature node name
|
||||
"""
|
||||
self.__handle = handle
|
||||
self.__feature_name = feature_name
|
||||
|
||||
class IntFeature_s(Feature_s):
|
||||
def __init__(self, handle, feature_name):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface featrue control handle\Device local layer feature control\Device remote layer featrure control\Device stream layer feature control
|
||||
:param feature_name: Feature node name
|
||||
"""
|
||||
Feature_s.__init__( self, handle, feature_name)
|
||||
self.__handle = handle
|
||||
self.__feature_name = feature_name
|
||||
|
||||
def __range_dicts(self, feature_value):
|
||||
"""
|
||||
:brief Convert feature info to list
|
||||
:param feature_value: Int type feature info
|
||||
:return: Feature info list
|
||||
"""
|
||||
range_dicts = {
|
||||
"value" : feature_value.value,
|
||||
"min" : feature_value.min,
|
||||
"max" : feature_value.max,
|
||||
"inc" : feature_value.inc,
|
||||
"reserved" : array_decoding( feature_value.reserved),
|
||||
}
|
||||
return range_dicts
|
||||
|
||||
def get_range(self):
|
||||
"""
|
||||
:brief Getting integer range
|
||||
:return: integer range dictionary
|
||||
"""
|
||||
status, int_feature_info = gx_get_int_feature(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'IntFeature_s', 'get_range')
|
||||
|
||||
return self.__range_dicts( int_feature_info)
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting value of Enum feature
|
||||
:return: enum_value: enum value
|
||||
enum_str: string for enum description
|
||||
"""
|
||||
status, int_feature_info = gx_get_int_feature(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'IntFeature_s', 'get')
|
||||
|
||||
return int_feature_info.value
|
||||
|
||||
def set(self, int_value):
|
||||
"""
|
||||
:brief Setting integer value
|
||||
:param int_value: Set value
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(int_value, INT_TYPE):
|
||||
raise ParameterTypeError("IntFeature_s.set: "
|
||||
"Expected int_value type is int, not %s" % type(int_value))
|
||||
|
||||
status = gx_set_int_feature_value(self.__handle, self.__feature_name, int_value)
|
||||
StatusProcessor.process(status, 'IntFeature_s', 'set')
|
||||
|
||||
class EnumFeature_s(Feature_s):
|
||||
def __init__(self, handle, feature_name):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface featrue control handle\Device local layer feature control\Device remote layer featrure control\Device stream layer feature control
|
||||
:param feature_name: Feature node name
|
||||
"""
|
||||
Feature_s.__init__( self, handle, feature_name)
|
||||
self.__handle = handle
|
||||
self.__feature_name = feature_name
|
||||
|
||||
def __range_dicts(self, feature_value):
|
||||
enum_dict = []
|
||||
for index in range(feature_value.supported_number):
|
||||
enum_dict.append({
|
||||
"value" : feature_value.supported_value[index].cur_value,
|
||||
"symbolic" : string_decoding( feature_value.supported_value[index].cur_symbolic),
|
||||
})
|
||||
return enum_dict
|
||||
|
||||
def get_range(self):
|
||||
"""
|
||||
:brief Getting range of Enum feature
|
||||
:return: enum_dict: enum range dictionary
|
||||
"""
|
||||
status, enum_feature_info = gx_get_enum_feature( self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'gx_get_enum_feature')
|
||||
|
||||
return self.__range_dicts( enum_feature_info)
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting value of Enum feature
|
||||
:return: enum_value: enum value
|
||||
enum_str: string for enum description
|
||||
"""
|
||||
status, enum_feature_info = gx_get_enum_feature(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'FeatureControl', 'gx_get_enum_feature')
|
||||
|
||||
return enum_feature_info.cur_value.cur_value, string_decoding( enum_feature_info.cur_value.cur_symbolic)
|
||||
|
||||
def set(self, enum_value):
|
||||
"""
|
||||
:brief Setting enum value
|
||||
:param enum_value
|
||||
:return: None
|
||||
"""
|
||||
if isinstance(enum_value, int):
|
||||
status = gx_set_enum_feature_value(self.__handle, self.__feature_name, enum_value)
|
||||
StatusProcessor.process(status, 'EnumFeature_s', 'set')
|
||||
elif isinstance(enum_value, str):
|
||||
status = gx_set_enum_feature_value_string( self.__handle, self.__feature_name, enum_value)
|
||||
StatusProcessor.process(status, 'EnumFeature_s', 'set')
|
||||
else:
|
||||
raise ParameterTypeError("EnumFeature_s.set: "
|
||||
"Expected enum_value type is int or string, not %s" % type(enum_value))
|
||||
|
||||
class FloatFeature_s(Feature_s):
|
||||
def __init__(self, handle, feature_name):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface featrue control handle\Device local layer feature control\Device remote layer featrure control\Device stream layer feature control
|
||||
:param feature_name: Feature node name
|
||||
"""
|
||||
Feature_s.__init__( self, handle, feature_name)
|
||||
self.__handle = handle
|
||||
self.__feature_name = feature_name
|
||||
|
||||
def __range_dict(self, feature_value):
|
||||
"""
|
||||
:brief Convert GxFloatRange to dictionary
|
||||
:param float_range: GxFloatRange
|
||||
:return: range_dicts
|
||||
"""
|
||||
range_dicts = {
|
||||
"cur_value" : feature_value.cur_value,
|
||||
"min" : feature_value.min,
|
||||
"max" : feature_value.max,
|
||||
"inc" : feature_value.inc,
|
||||
"inc_is_valid" : feature_value.inc_is_valid,
|
||||
"unit" : string_decoding( feature_value.unit),
|
||||
"reserved" : array_decoding( feature_value.reserved),
|
||||
}
|
||||
return range_dicts
|
||||
|
||||
def get_range(self):
|
||||
"""
|
||||
:brief Getting float range
|
||||
:return: float range dictionary
|
||||
"""
|
||||
status, float_feature_info = gx_get_float_feature(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'FloatFeature_s', 'get_range')
|
||||
return self.__range_dict( float_feature_info)
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting float value
|
||||
:return: float value
|
||||
"""
|
||||
status, float_feature_info = gx_get_float_feature(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'FloatFeature_s', 'get_range')
|
||||
return float_feature_info.cur_value
|
||||
|
||||
def set(self, float_value):
|
||||
"""
|
||||
:brief Setting float value
|
||||
:param float_value
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(float_value, float):
|
||||
raise ParameterTypeError("FloatFeature_s.set: "
|
||||
"Expected float_value type is int, not %s" % type(float_value))
|
||||
|
||||
status = gx_set_float_feature_value(self.__handle, self.__feature_name, float_value)
|
||||
StatusProcessor.process(status, 'FloatFeature_s', 'set')
|
||||
|
||||
class BoolFeature_s(Feature_s):
|
||||
def __init__(self, handle, feature_name):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface featrue control handle\Device local layer feature control\Device remote layer featrure control\Device stream layer feature control
|
||||
:param feature_name: Feature node name
|
||||
"""
|
||||
Feature_s.__init__( self, handle, feature_name)
|
||||
self.__handle = handle
|
||||
self.__feature_name = feature_name
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting bool value
|
||||
:return: bool value[bool]
|
||||
"""
|
||||
status, bool_feature_value = gx_get_bool_feature( self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'BoolFeature_s', 'get')
|
||||
return bool_feature_value
|
||||
|
||||
def set(self, bool_value):
|
||||
"""
|
||||
:brief Setting bool value
|
||||
:param bool_value[bool]
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(bool_value, bool):
|
||||
raise ParameterTypeError("BoolFeature_s.set: "
|
||||
"Expected bool_value type is int, not %s" % type(bool_value))
|
||||
|
||||
status = gx_set_bool_feature_value( self.__handle, self.__feature_name, bool_value)
|
||||
StatusProcessor.process(status, 'BoolFeature_s', 'set')
|
||||
|
||||
class StringFeature_s(Feature_s):
|
||||
def __init__(self, handle, feature_name):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface featrue control handle\Device local layer feature control\Device remote layer featrure control\Device stream layer feature control
|
||||
:param feature_name: Feature node name
|
||||
"""
|
||||
Feature_s.__init__( self, handle, feature_name)
|
||||
self.__handle = handle
|
||||
self.__feature_name = feature_name
|
||||
|
||||
def get_string_max_length(self):
|
||||
"""
|
||||
:brief String max length
|
||||
:return: Max length
|
||||
"""
|
||||
status, string_value = gx_get_string_feature( self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'StringFeature_s', 'get_string_max_length')
|
||||
return string_value.max_length
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
:brief Getting string value
|
||||
:return: strings
|
||||
"""
|
||||
status, string_value = gx_get_string_feature(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'StringFeature_s', 'get')
|
||||
return string_decoding( string_value.cur_value)
|
||||
|
||||
def set(self, input_string):
|
||||
"""
|
||||
:brief Setting string value
|
||||
:param input_string[string]
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(input_string, str):
|
||||
raise ParameterTypeError("StringFeature_s.set: "
|
||||
"Expected input_string type is int, not %s" % type(input_string))
|
||||
|
||||
status = gx_set_string_feature_value( self.__handle, self.__feature_name, input_string)
|
||||
StatusProcessor.process(status, 'StringFeature_s', 'set')
|
||||
|
||||
class CommandFeature_s(Feature_s):
|
||||
def __init__(self, handle, feature_name):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface featrue control handle\Device local layer feature control\Device remote layer featrure control\Device stream layer feature control
|
||||
:param feature_name: Feature node name
|
||||
"""
|
||||
Feature_s.__init__( self, handle, feature_name)
|
||||
self.__handle = handle
|
||||
self.__feature_name = feature_name
|
||||
|
||||
def send_command(self):
|
||||
"""
|
||||
:brief Sending command
|
||||
:return: None
|
||||
"""
|
||||
status = gx_feature_send_command(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'CommandFeature_s', 'send_command')
|
||||
|
||||
|
||||
class RegisterFeature_s(Feature_s):
|
||||
def __init__(self, handle, feature_name):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface featrue control handle\Device local layer feature control\Device remote layer featrure control\Device stream layer feature control
|
||||
:param feature_name: Feature node name
|
||||
"""
|
||||
Feature_s.__init__( self, handle, feature_name)
|
||||
self.__handle = handle
|
||||
self.__feature_name = feature_name
|
||||
|
||||
def get_register_length(self):
|
||||
"""
|
||||
:brief Getting buffer length
|
||||
:return: length: buffer length
|
||||
"""
|
||||
status, register_feature_length = gx_get_register_feature_length(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'RegisterFeature_s', 'get_register_length')
|
||||
return register_feature_length
|
||||
|
||||
def get_buffer(self):
|
||||
"""
|
||||
:brief Getting buffer data
|
||||
:return: Buffer object
|
||||
"""
|
||||
status, register_feature_value = gx_get_register_feature_value(self.__handle, self.__feature_name)
|
||||
StatusProcessor.process(status, 'RegisterFeature_s', 'get_buffer')
|
||||
return Buffer(register_feature_value)
|
||||
|
||||
def set_buffer(self, buf):
|
||||
"""
|
||||
:brief Setting buffer data
|
||||
:param buf: Buffer object
|
||||
:return: None
|
||||
"""
|
||||
if not isinstance(buf, Buffer):
|
||||
raise ParameterTypeError("RegisterFeature_s.set_buffer: "
|
||||
"Expected buff type is Buffer, not %s" % type(buf))
|
||||
|
||||
max_length = self.get_register_length()
|
||||
if buf.get_length() > max_length:
|
||||
print("RegisterFeature_s.set_buffer: "
|
||||
"buff length out of bounds, %s.length_max:%s" % (self.__feature_name, max_length))
|
||||
|
||||
raise UnexpectedError("buff length out of bounds, %s.length_max:%d" % (self.__feature_name, max_length))
|
||||
|
||||
status = gx_set_register_feature_value(self.__handle, self.__feature_name,buf.get_ctype_array(), buf.get_length())
|
||||
StatusProcessor.process(status, 'RegisterFeature_s', 'set_buffer')
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,486 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
|
||||
import numpy
|
||||
|
||||
from .. import gxipy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .ImageFormatConvert import *
|
||||
from .ImageProcessConfig import *
|
||||
from .Exception import *
|
||||
import types
|
||||
|
||||
class ImageProcess:
|
||||
|
||||
def __init__(self):
|
||||
self.image_convert_handle = None
|
||||
|
||||
def __new__(cls, *args, **kw):
|
||||
return object.__new__(cls, *args)
|
||||
|
||||
def __del__(self):
|
||||
if self.image_convert_handle is not None:
|
||||
status = dx_image_format_convert_destroy(self.image_convert_handle)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_destroy failure, Error code:%s" % hex(status).__str__())
|
||||
self.image_convert_handle = None
|
||||
|
||||
def image_improvement(self, image, output_address, image_process_config):
|
||||
"""
|
||||
:brief: Improve image quality of the raw_image
|
||||
:param image: image is RawImage or GXImageInfo
|
||||
|
||||
:param output_address: output image
|
||||
:param image_process_config: image process config
|
||||
:param
|
||||
:return: None
|
||||
"""
|
||||
if output_address is None:
|
||||
raise ParameterTypeError("output_address param is null pointer.")
|
||||
|
||||
if not isinstance(image_process_config, ImageProcessConfig):
|
||||
raise ParameterTypeError("image_process_config param must be ImageProcessConfig type.")
|
||||
|
||||
pixel_format = GxPixelFormatEntry.UNDEFINED
|
||||
raw_image_width = 0
|
||||
raw_image_height = 0
|
||||
input_image_buffer = None
|
||||
channel_order = DxRGBChannelOrder.ORDER_RGB
|
||||
if isinstance(image, (RawImage, RGBImage)):
|
||||
pixel_format = image.frame_data.pixel_format
|
||||
raw_image_width = image.frame_data.width
|
||||
raw_image_height = image.frame_data.height
|
||||
input_image_buffer = image.frame_data.image_buf
|
||||
elif isinstance(image, GxImageInfo):
|
||||
pixel_format = image.image_pixel_format
|
||||
raw_image_width = image.image_width
|
||||
raw_image_height = image.image_height
|
||||
input_image_buffer = image.image_buf
|
||||
else:
|
||||
raise ParameterTypeError("image param must be RawImage or GxImageInfo type.")
|
||||
|
||||
if input_image_buffer is None:
|
||||
raise ParameterTypeError("input_image_buffer param is null pointer.")
|
||||
|
||||
if pixel_format == GxPixelFormatEntry.RGB8:
|
||||
channel_order = DxRGBChannelOrder.ORDER_RGB
|
||||
elif pixel_format == GxPixelFormatEntry.BGR8:
|
||||
channel_order = DxRGBChannelOrder.ORDER_BGR
|
||||
|
||||
if pixel_format in (GxPixelFormatEntry.RGB8, GxPixelFormatEntry.BGR8):
|
||||
if pixel_format == GxPixelFormatEntry.BGR8:
|
||||
|
||||
self.__check_handle()
|
||||
status = dx_image_format_convert_set_output_pixel_format(self.image_convert_handle,
|
||||
GxPixelFormatEntry.RGB8)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_set_output_pixel_format failure, Error code:%s" % hex(
|
||||
status).__str__())
|
||||
|
||||
status = dx_image_format_convert_set_valid_bits(self.image_convert_handle, DxValidBit.BIT0_7)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"image_format_convert_set_alpha_value failure, Error code:%s" % hex(status).__str__())
|
||||
|
||||
status, out_lenght = dx_image_format_convert_get_buffer_size_for_conversion(self.image_convert_handle,
|
||||
GxPixelFormatEntry.RGB8,
|
||||
image.frame_data.width,
|
||||
image.frame_data.height)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_get_buffer_size_for_conversion failure, Error code:%s" % hex(
|
||||
status).__str__())
|
||||
|
||||
image_temp = (c_ubyte * out_lenght)()
|
||||
output_image_temp = addressof(image_temp)
|
||||
|
||||
status, input_length = dx_image_format_convert_get_buffer_size_for_conversion(self.image_convert_handle,
|
||||
image.frame_data.pixel_format,
|
||||
image.frame_data.width,
|
||||
image.frame_data.height)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_get_buffer_size_for_conversion failure, Error code:%s" % hex(
|
||||
status).__str__())
|
||||
|
||||
status = dx_image_format_convert(self.image_convert_handle, image.frame_data.image_buf, input_length,
|
||||
output_image_temp,
|
||||
out_lenght, image.frame_data.pixel_format,
|
||||
image.frame_data.width, image.frame_data.height, False)
|
||||
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("image_format_convert failure, Error code:%s" % hex(status).__str__())
|
||||
|
||||
input_image_buffer = output_image_temp
|
||||
status = dx_image_improvement_ex(input_image_buffer, output_address,
|
||||
raw_image_width, raw_image_height,
|
||||
image_process_config.get_color_correction_param(),
|
||||
image_process_config.get_contrast_lut().get_ctype_array(),
|
||||
image_process_config.get_gamma_lut().get_ctype_array(),
|
||||
channel_order)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("RGBImage.image_improvement: failed, error code:%s" % hex(status).__str__())
|
||||
return
|
||||
|
||||
if Utility.is_gray(pixel_format):
|
||||
ImageProcess.__mono_image_process(self, output_address, image, image_process_config)
|
||||
else:
|
||||
rgb_image_array_temp = (c_ubyte * image.frame_data.height * image.frame_data.width * 3)()
|
||||
rgb_image_array_temp_address = addressof(rgb_image_array_temp)
|
||||
ImageProcess.__raw_image_process(rgb_image_array_temp_address, image, image_process_config)
|
||||
|
||||
# convert to rgb
|
||||
self.__check_handle()
|
||||
status = dx_image_format_convert_set_output_pixel_format(self.image_convert_handle,
|
||||
GxPixelFormatEntry.RGB8)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_set_output_pixel_format failure, Error code:%s" % hex(
|
||||
status).__str__())
|
||||
status = dx_image_format_convert_set_valid_bits(self.image_convert_handle, DxValidBit.BIT0_7)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"image_format_convert_set_alpha_value failure, Error code:%s" % hex(status).__str__())
|
||||
|
||||
status, out_lenght = dx_image_format_convert_get_buffer_size_for_conversion(self.image_convert_handle,
|
||||
GxPixelFormatEntry.BGR8,
|
||||
image.frame_data.width,
|
||||
image.frame_data.height)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_get_buffer_size_for_conversion failure, Error code:%s" % hex(
|
||||
status).__str__())
|
||||
|
||||
input_length = image.frame_data.width * image.frame_data.height * 3
|
||||
status = dx_image_format_convert(self.image_convert_handle, rgb_image_array_temp_address, input_length,
|
||||
output_address,
|
||||
out_lenght, GxPixelFormatEntry.BGR8,
|
||||
image.frame_data.width, image.frame_data.height, False)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("image_format_convert failure, Error code:%s" % hex(status).__str__())
|
||||
|
||||
|
||||
def static_defect_correction(self, input_address, output_address, defect_correction, defect_pos_buffer_address,
|
||||
defect_pos_buffer_size):
|
||||
"""
|
||||
:brief Image defect pixel correction
|
||||
:param input_address: The input raw image buff address, buff size = width * height
|
||||
:param output_address: The output rgb image buff address, buff size = width * height * 3
|
||||
:param defect_correction: Image parameter used to do defect correction
|
||||
:param defect_pos_buffer_address: Defect Pixel position file buffer
|
||||
:param defect_pos_buffer_size: Defect Pixel position file buffer size
|
||||
|
||||
:return: status State return value, See detail in DxStatus
|
||||
data_array Array of output images, buff size = width * height * 3
|
||||
"""
|
||||
if input_address is None:
|
||||
raise ParameterTypeError("input_address param is null pointer.")
|
||||
|
||||
if output_address is None:
|
||||
raise ParameterTypeError("output_address param is null pointer.")
|
||||
|
||||
if not isinstance(defect_correction, StaticDefectCorrection):
|
||||
raise ParameterTypeError("StaticDefectCorrection param must be StaticDefectCorrection type.")
|
||||
|
||||
if defect_pos_buffer_address is None:
|
||||
raise ParameterTypeError("defect_pos_buffer_address param is null pointer.")
|
||||
|
||||
if not isinstance(defect_pos_buffer_size, INT_TYPE):
|
||||
raise ParameterTypeError("defect_pos_buffer_size param must be Int type.")
|
||||
|
||||
status = dx_static_defect_correction(input_address, output_address, defect_correction, defect_pos_buffer_address,
|
||||
defect_pos_buffer_size)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("dx_static_defect_correction failure, Error code:%s" % hex(status).__str__())
|
||||
|
||||
|
||||
@staticmethod
|
||||
def calcula_lut(contrast_param, gamma, light_ness, lut_address,
|
||||
lut_length_address):
|
||||
"""
|
||||
:brief calculating lookup table of camera
|
||||
:param contrast_param: contrast param,range(-50~100)
|
||||
:param gamma: gamma param,range(0.1~10)
|
||||
:param light_ness: lightness param,range(-150~150)
|
||||
:param lut_address: lookup table
|
||||
:param lut_length_address: lookup table length(unit:byte)
|
||||
|
||||
Lookup table length should be obtained through the interface GXGetBufferLength.
|
||||
:return: status State return value, See detail in DxStatus
|
||||
data_array Array of output images, buff size = width * height * 3
|
||||
"""
|
||||
if not (isinstance(contrast_param, INT_TYPE)):
|
||||
raise ParameterTypeError("contrast_param param must to be int type.")
|
||||
|
||||
if not (isinstance(gamma, (INT_TYPE, float))):
|
||||
raise ParameterTypeError("gamma param must to be int or float type.")
|
||||
|
||||
if not (isinstance(light_ness, INT_TYPE)):
|
||||
raise ParameterTypeError("light_ness param must to be int type.")
|
||||
|
||||
if lut_address is None:
|
||||
raise ParameterTypeError("lut_address is NULL pointer")
|
||||
|
||||
if lut_length_address is None:
|
||||
raise ParameterTypeError("lut_length_address is NULL pointer")
|
||||
|
||||
status = dx_calc_camera_lut_buffer(contrast_param, gamma, light_ness, lut_address,
|
||||
lut_length_address)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("calc_camera_lut_buffer failure, Error code:%s" % hex(status).__str__())
|
||||
|
||||
@staticmethod
|
||||
def read_lut_file(lut_file_path, lut_address, lut_length_address):
|
||||
"""
|
||||
:brief read lut file
|
||||
:param lut_file_path: Lut file path. Lut file(xxx.lut) can be obtained from Lut
|
||||
Create Tool Plugin,which can be get by select Plugin->Lut
|
||||
Create Tool Plugin from the menu bar in GalaxyView.
|
||||
:param lut_address: Lookup table. Users need to apply for memory in advance.The
|
||||
memory size is also lookup table length(nLutLength),should be
|
||||
obtained through the interface GXGetBufferLength,
|
||||
e.g. GXGetBufferLength(m_hDevice, GX_BUFFER_LUT_VALUEALL,&nLutLength),
|
||||
:param lut_length_address: Lookup table length(unit:byte),which should be obtained through
|
||||
the interface GXGetBufferLength, e.g.
|
||||
GXGetBufferLength(m_hDevice, GX_BUFFER_LUT_VALUEALL,&nLutLength),
|
||||
:return: status State return value, See detail in DxStatus
|
||||
data_array Array of output images, buff size = width * height * 3
|
||||
"""
|
||||
|
||||
if os.path.exists(lut_file_path) is False:
|
||||
raise ParameterTypeError("%s file is not exits" % lut_file_path)
|
||||
|
||||
if lut_address is None:
|
||||
raise ParameterTypeError("lut_address is NULL pointer")
|
||||
|
||||
if lut_length_address is None:
|
||||
raise ParameterTypeError("lut_length_address is NULL pointer")
|
||||
|
||||
path = create_string_buffer(string_encoding(lut_file_path))
|
||||
|
||||
status = dx_read_lut_file(path, lut_address, lut_length_address)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("read_lut_file failure, Error code:%s" % hex(status).__str__())
|
||||
|
||||
@staticmethod
|
||||
def __is_bayer(pixel_format):
|
||||
bayer_gr8_id = (GxPixelFormatEntry.BAYER_GR8 & PIXEL_ID_MASK)
|
||||
bayer_bg12_id = (GxPixelFormatEntry.BAYER_BG12 & PIXEL_ID_MASK)
|
||||
|
||||
bayer_gr16_id = (GxPixelFormatEntry.BAYER_GR16 & PIXEL_ID_MASK)
|
||||
bayer_bg16_id = (GxPixelFormatEntry.BAYER_BG16 & PIXEL_ID_MASK)
|
||||
if ((pixel_format & PIXEL_ID_MASK) >= bayer_gr8_id) and ((pixel_format & PIXEL_ID_MASK) <= bayer_bg12_id):
|
||||
return True
|
||||
elif ((pixel_format & PIXEL_ID_MASK) >= bayer_gr16_id) and ((pixel_format & PIXEL_ID_MASK) <= bayer_bg16_id):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def __is_gray(pixel_format):
|
||||
if (pixel_format & PIXEL_COLOR_MASK) != PIXEL_MONO:
|
||||
return False
|
||||
elif (ImageProcess.__is_bayer(pixel_format)):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def __get_pixel_color_filter(pixel_format):
|
||||
"""
|
||||
:brief Calculate pixel color filter based on pixel format
|
||||
:param pixel_format
|
||||
:return: pixel color filter
|
||||
"""
|
||||
gr_tup = (GxPixelFormatEntry.BAYER_GR8, GxPixelFormatEntry.BAYER_GR10,
|
||||
GxPixelFormatEntry.BAYER_GR12, GxPixelFormatEntry.BAYER_GR16)
|
||||
rg_tup = (GxPixelFormatEntry.BAYER_RG8, GxPixelFormatEntry.BAYER_RG10,
|
||||
GxPixelFormatEntry.BAYER_RG12, GxPixelFormatEntry.BAYER_RG16)
|
||||
gb_tup = (GxPixelFormatEntry.BAYER_GB8, GxPixelFormatEntry.BAYER_GB10,
|
||||
GxPixelFormatEntry.BAYER_GB12, GxPixelFormatEntry.BAYER_GB16)
|
||||
bg_tup = (GxPixelFormatEntry.BAYER_BG8, GxPixelFormatEntry.BAYER_BG10,
|
||||
GxPixelFormatEntry.BAYER_BG12, GxPixelFormatEntry.BAYER_BG16)
|
||||
mono_tup = (GxPixelFormatEntry.MONO8, GxPixelFormatEntry.MONO8_SIGNED,
|
||||
GxPixelFormatEntry.MONO10, GxPixelFormatEntry.MONO12,
|
||||
GxPixelFormatEntry.MONO14, GxPixelFormatEntry.MONO16,
|
||||
GxPixelFormatEntry.MONO10_PACKED, GxPixelFormatEntry.MONO12_PACKED)
|
||||
|
||||
if pixel_format in gr_tup:
|
||||
return DxPixelColorFilter.GR
|
||||
elif pixel_format in rg_tup:
|
||||
return DxPixelColorFilter.RG
|
||||
elif pixel_format in gb_tup:
|
||||
return DxPixelColorFilter.GB
|
||||
elif pixel_format in bg_tup:
|
||||
return DxPixelColorFilter.BG
|
||||
elif pixel_format in mono_tup:
|
||||
return DxPixelColorFilter.NONE
|
||||
else:
|
||||
return -1
|
||||
|
||||
@staticmethod
|
||||
def __raw_image_process(output_address, image, image_process_config):
|
||||
"""
|
||||
:brief Raw8 image process
|
||||
:param color_img_process_param: image process param, refer to DxColorImgProcess
|
||||
:return img_rgb
|
||||
"""
|
||||
pixel_format = 0
|
||||
raw_image_width = 0
|
||||
raw_image_height = 0
|
||||
input_image_buffer = None
|
||||
if isinstance(image, (RawImage, RGBImage)):
|
||||
pixel_format = image.frame_data.pixel_format
|
||||
raw_image_width = image.frame_data.width
|
||||
raw_image_height = image.frame_data.height
|
||||
input_image_buffer = image.frame_data.image_buf
|
||||
elif isinstance(image, GxImageInfo):
|
||||
pixel_format = image.image_pixel_format
|
||||
raw_image_width = image.image_width
|
||||
raw_image_height = image.image_height
|
||||
input_image_buffer = image.image_buf
|
||||
else:
|
||||
raise ParameterTypeError("image param must be RawImage or GxImageInfo type")
|
||||
|
||||
if input_image_buffer is None or output_address is None:
|
||||
raise ParameterTypeError("input_image_buffer or output_address is NULL pointer")
|
||||
|
||||
if pixel_format & PIXEL_BIT_MASK != GX_PIXEL_8BIT:
|
||||
status = dx_raw16_to_raw8(input_image_buffer, input_image_buffer,
|
||||
raw_image_width, raw_image_height,
|
||||
image_process_config.get_valid_bits())
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("RawImage.convert: raw16 convert to raw8 failed, Error core: %s"
|
||||
% hex(status).__str__())
|
||||
|
||||
color_filter = ImageProcess.__get_pixel_color_filter(pixel_format)
|
||||
mutex = image_process_config.get_mutex()
|
||||
with mutex:
|
||||
color_img_process_param = image_process_config.get_color_image_process(color_filter)
|
||||
status = dx_raw8_image_process(input_image_buffer, output_address,
|
||||
raw_image_width, raw_image_height, color_img_process_param)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("RawImage.raw8_image_process: failed, error code:%s" % hex(status).__str__())
|
||||
|
||||
def __mono_image_process(self, output_address, image, image_process_config):
|
||||
"""
|
||||
:brief mono8 image process
|
||||
:param mono_img_process_param: image process param, refer to DxMonoImgProcess
|
||||
:return img_mono
|
||||
"""
|
||||
pixel_format = 0
|
||||
raw_image_width = 0
|
||||
raw_image_height = 0
|
||||
input_image_buffer = None
|
||||
if isinstance(image, (RawImage, RGBImage)):
|
||||
pixel_format = image.frame_data.pixel_format
|
||||
raw_image_width = image.frame_data.width
|
||||
raw_image_height = image.frame_data.height
|
||||
input_image_buffer = image.frame_data.image_buf
|
||||
elif isinstance(image, GxImageInfo):
|
||||
pixel_format = image.image_pixel_format
|
||||
raw_image_width = image.image_width
|
||||
raw_image_height = image.image_height
|
||||
input_image_buffer = image.image_buf
|
||||
else:
|
||||
raise ParameterTypeError("image param must be RawImage or GxImageInfo type")
|
||||
|
||||
if input_image_buffer is None or output_address is None:
|
||||
raise ParameterTypeError("input_image_buffer or output_address is NULL pointer")
|
||||
|
||||
if ((pixel_format & PIXEL_BIT_MASK) != GX_PIXEL_8BIT):
|
||||
image_temp = None
|
||||
output_image_temp = None
|
||||
if self.__is_packed_pixel_format(pixel_format):
|
||||
self.__check_handle()
|
||||
status = dx_image_format_convert_set_output_pixel_format(self.image_convert_handle, GxPixelFormatEntry.MONO8)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_set_output_pixel_format failure, Error code:%s" % hex(
|
||||
status).__str__())
|
||||
|
||||
status, out_lenght = dx_image_format_convert_get_buffer_size_for_conversion(self.image_convert_handle, GxPixelFormatEntry.MONO8,
|
||||
raw_image_width, raw_image_height)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_get_buffer_size_for_conversion failure, Error code:%s" % hex(
|
||||
status).__str__())
|
||||
|
||||
image_temp = (c_ubyte * out_lenght)()
|
||||
output_image_temp = addressof(image_temp)
|
||||
|
||||
status, input_length = dx_image_format_convert_get_buffer_size_for_conversion(self.image_convert_handle, pixel_format,
|
||||
raw_image_width, raw_image_height)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"dx_image_format_convert_get_buffer_size_for_conversion failure, Error code:%s" % hex(
|
||||
status).__str__())
|
||||
|
||||
status = dx_image_format_convert(self.image_convert_handle, input_image_buffer, input_length,
|
||||
output_image_temp,
|
||||
out_lenght, pixel_format,
|
||||
raw_image_width, raw_image_height, False)
|
||||
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("image_format_convert failure, Error code:%s" % hex(status).__str__())
|
||||
else:
|
||||
image_temp = (c_ubyte * raw_image_width *raw_image_height)()
|
||||
output_image_temp = addressof(image_temp)
|
||||
|
||||
status = dx_raw16_to_raw8(input_image_buffer, output_image_temp,
|
||||
raw_image_width, raw_image_height,
|
||||
image_process_config.get_valid_bits())
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("RawImage.convert: raw16 convert to raw8 failed, Error core: %s"
|
||||
% hex(status).__str__())
|
||||
|
||||
input_image_buffer = output_image_temp
|
||||
|
||||
mutex = image_process_config.get_mutex()
|
||||
with mutex:
|
||||
mono_img_process_param = image_process_config.get_mono_image_process()
|
||||
status = dx_mono8_image_process(input_image_buffer, output_address,
|
||||
raw_image_width, raw_image_height, mono_img_process_param)
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError(
|
||||
"RawImage.dx_mono8_image_process: failed, error code:%s" % hex(status).__str__())
|
||||
|
||||
def __check_handle(self):
|
||||
"""
|
||||
:brief The transformation handle is initialized the first time it is called
|
||||
:return NONE
|
||||
"""
|
||||
if self.image_convert_handle is None:
|
||||
status, handle = dx_image_format_convert_create()
|
||||
if status != DxStatus.OK:
|
||||
raise UnexpectedError("dx_image_format_convert_create failure, Error code:%s" % hex(status).__str__())
|
||||
self.image_convert_handle = handle
|
||||
|
||||
|
||||
def __get_pixel_bit(self, pixel_format):
|
||||
"""
|
||||
:brief get pixel bit
|
||||
:return pixel bit
|
||||
"""
|
||||
return (pixel_format & PIXEL_BIT_MASK)
|
||||
|
||||
def __is_packed_pixel_format(self, pixel_format):
|
||||
"""
|
||||
:brief Get whether it is in packed pixel format
|
||||
|
||||
:return true is packed , false is not packed
|
||||
"""
|
||||
pixel_bit = self.__get_pixel_bit(pixel_format)
|
||||
if (pixel_format & PIXEL_MONO):
|
||||
if pixel_bit in (gxipy.GX_PIXEL_10BIT, gxipy.GX_PIXEL_12BIT, gxipy.GX_PIXEL_14BIT,):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .FeatureControl import *
|
||||
from .StatusProcessor import *
|
||||
import types
|
||||
|
||||
class Interface:
|
||||
def __init__(self, handle, interface_info):
|
||||
"""
|
||||
:brief Constructor for instance initialization
|
||||
:param handle: Interface Handle
|
||||
:param interface_info: Interface info list
|
||||
"""
|
||||
self.__interface_handle = handle
|
||||
self.__interface_info = interface_info
|
||||
|
||||
def get_interface_info(self):
|
||||
"""
|
||||
:brief Get interface info list
|
||||
:return: __interface_info
|
||||
"""
|
||||
return self.__interface_info
|
||||
|
||||
#def get_all_device_info_list(self):
|
||||
# return None
|
||||
|
||||
def get_feature_control(self):
|
||||
"""
|
||||
:brief Get interface feature control object
|
||||
:return: Interface feature control object
|
||||
"""
|
||||
feature_control = FeatureControl( self.__interface_handle)
|
||||
return feature_control
|
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .gxiapi import *
|
||||
from .Exception import *
|
||||
import types
|
||||
|
||||
ERROR_SIZE = 1024
|
||||
|
||||
class StatusProcessor:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def process(status, class_name, function_name):
|
||||
"""
|
||||
:brief 1.Error code processing
|
||||
2.combine the class name and function name of the transmitted function into a string
|
||||
3.Throw an exception
|
||||
:param status: function return value
|
||||
:param class_name: class name
|
||||
:param function_name: function name
|
||||
:return: none
|
||||
"""
|
||||
if status != GxStatusList.SUCCESS:
|
||||
ret, err_code, string = gx_get_last_error(ERROR_SIZE)
|
||||
error_message = "%s.%s:%s" % (class_name, function_name, string)
|
||||
exception_deal(status, error_message)
|
||||
|
||||
@staticmethod
|
||||
def printing(status, class_name, function_name):
|
||||
"""
|
||||
:brief 1.Error code processing
|
||||
2.combine the class name and function name of the transmitted function into a string and print it out
|
||||
:param status: function return value
|
||||
:param class_name: class name
|
||||
:param function_name: function name
|
||||
:return: none
|
||||
"""
|
||||
if status != GxStatusList.SUCCESS:
|
||||
ret, err_code, string = gx_get_last_error(ERROR_SIZE)
|
||||
error_message = "%s.%s:%s" % (class_name, function_name, string)
|
||||
print(error_message)
|
||||
|
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
from .gxiapi import *
|
||||
from .gxidef import *
|
||||
|
||||
|
||||
__all__ = ["gxwrapper", "dxwrapper", "gxiapi", "gxidef"]
|
||||
|
||||
__version__ = '2.0.2405.9231'
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding:utf-8 -*-
|
||||
# -*-mode:python ; tab-width:4 -*- ex:set tabstop=4 shiftwidth=4 expandtab: -*-
|
||||
|
||||
import numpy
|
||||
from .gxwrapper import *
|
||||
from .dxwrapper import *
|
||||
from .gxidef import *
|
||||
from .DeviceManager import *
|
||||
from .StatusProcessor import *
|
||||
from .ImageProc import *
|
||||
import types
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -1,7 +1,9 @@
|
||||
from fastapi import APIRouter
|
||||
from .views import agv_router
|
||||
|
||||
from .testAPI import agv_test_router
|
||||
router = APIRouter(prefix='/api/scheduler')
|
||||
|
||||
|
||||
router.include_router(agv_router, tags=["AGV小车状态"])
|
||||
router.include_router(agv_router, tags=["AGV小车控制"])
|
||||
|
||||
router.include_router(agv_test_router, tags=["AGV小车测试"])
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,55 @@
|
||||
[
|
||||
{
|
||||
"01-0154-1-1": {
|
||||
"cap": 30,
|
||||
"name": "试剂1",
|
||||
"action": 5,
|
||||
"bottle": 60,
|
||||
"height": 156,
|
||||
"orderid": "tr43frr",
|
||||
"traynum": "1X01",
|
||||
"quantity": 1,
|
||||
"typetask": 1,
|
||||
"coordinates": "01-0111-1-1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0154-1-2": {
|
||||
"cap": 30,
|
||||
"name": "试剂4",
|
||||
"action": 5,
|
||||
"bottle": 60,
|
||||
"height": 156,
|
||||
"orderid": "tr43frr",
|
||||
"traynum": "1X01",
|
||||
"quantity": 1,
|
||||
"typetask": 1,
|
||||
"coordinates": "01-0111-1-2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0155-1-1": {
|
||||
"cap": 30,
|
||||
"name": "试剂3",
|
||||
"action": 5,
|
||||
"bottle": 60,
|
||||
"height": 156,
|
||||
"orderid": "tr43frr",
|
||||
"traynum": "1R07",
|
||||
"quantity": 1,
|
||||
"typetask": 3,
|
||||
"coordinates": "01-0115-3-5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0150-1": {
|
||||
"name": "试剂2",
|
||||
"action": 5,
|
||||
"orderid": "tr43frr",
|
||||
"traynum": "1V04",
|
||||
"quantity": 1,
|
||||
"typetask": 9,
|
||||
"coordinates": "01-0114-1"
|
||||
}
|
||||
}
|
||||
]
|
@ -0,0 +1,136 @@
|
||||
{
|
||||
"code": 200,
|
||||
"desc": "成功",
|
||||
"data": {
|
||||
"code": 200,
|
||||
"desc": "成功",
|
||||
"data": {
|
||||
"id": "6e746567-31ba-4c32-be58-c6b700deeb64",
|
||||
"num": "48TB",
|
||||
"orderid": "tr43frr",
|
||||
"sequence": 0,
|
||||
"ordertime": "2024-08-23 00:00:00+08:00",
|
||||
"agvid": "001",
|
||||
"itinerary": [
|
||||
"01-0111",
|
||||
"01-0114",
|
||||
"01-0115"
|
||||
],
|
||||
"cmd": [
|
||||
{
|
||||
"01-0154-1-1": {
|
||||
"orderid": "tr43frr",
|
||||
"name": "试剂5",
|
||||
"typetask": 1,
|
||||
"action": 5,
|
||||
"quantity": 1,
|
||||
"height": 156,
|
||||
"bottle": 60,
|
||||
"cap": 30,
|
||||
"coordinates": "01-0111-1-5",
|
||||
"traynum": "1X09"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0154-1-2": {
|
||||
"orderid": "tr43frr",
|
||||
"name": "试剂1",
|
||||
"typetask": 1,
|
||||
"action": 5,
|
||||
"quantity": 1,
|
||||
"height": 156,
|
||||
"bottle": 60,
|
||||
"cap": 30,
|
||||
"coordinates": "01-0111-1-1",
|
||||
"traynum": "1X01"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0155-1-1": {
|
||||
"orderid": "tr43frr",
|
||||
"name": "试剂3",
|
||||
"typetask": 3,
|
||||
"action": 5,
|
||||
"quantity": 1,
|
||||
"height": 156,
|
||||
"bottle": 60,
|
||||
"cap": 30,
|
||||
"coordinates": "01-0115-3-5",
|
||||
"traynum": "1R07"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0150-1": {
|
||||
"orderid": "tr43frr",
|
||||
"name": "试剂2",
|
||||
"typetask": 9,
|
||||
"action": 5,
|
||||
"quantity": 1,
|
||||
"coordinates": "01-0114-1",
|
||||
"traynum": "1V04"
|
||||
}
|
||||
}
|
||||
],
|
||||
"last": "01-0115",
|
||||
"loada": 2,
|
||||
"loadb": 1,
|
||||
"loadc": 0,
|
||||
"loadd": 0,
|
||||
"loade": 1,
|
||||
"is_canceled": false,
|
||||
"cancel_time": "None",
|
||||
"is_processing": false,
|
||||
"is_failed": false,
|
||||
"is_done": false,
|
||||
"is_valid": true,
|
||||
"updated_at": "2024-09-23 14:47:47.136985+08:00",
|
||||
"created_at": "2024-09-23 14:47:47.100262+08:00",
|
||||
"owner": {
|
||||
"id": "4f7cbe2e-dedf-4a6c-ae19-fb48820dc5fc",
|
||||
"username": "2346",
|
||||
"name": "2346",
|
||||
"is_locked": true,
|
||||
"phone": "7459344674",
|
||||
"email": "lsr@126.com"
|
||||
},
|
||||
"subtasks": [
|
||||
{
|
||||
"id": "1ddbc301-cfbb-4e85-acda-8f02b60cee29",
|
||||
"num": "WE8X",
|
||||
"name": "试剂5",
|
||||
"quantity": 1,
|
||||
"action": 5,
|
||||
"typetask": 1,
|
||||
"created_at": "2024-09-23 14:47:47.088605+08:00"
|
||||
},
|
||||
{
|
||||
"id": "e9c0642c-c1dc-4061-baa1-804b8028033f",
|
||||
"num": "XKJX",
|
||||
"name": "试剂1",
|
||||
"quantity": 1,
|
||||
"action": 5,
|
||||
"typetask": 1,
|
||||
"created_at": "2024-09-23 14:47:47.054199+08:00"
|
||||
},
|
||||
{
|
||||
"id": "968120de-ae77-422f-a992-f700cb769cfe",
|
||||
"num": "42AY",
|
||||
"name": "试剂2",
|
||||
"quantity": 1,
|
||||
"action": 5,
|
||||
"typetask": 9,
|
||||
"created_at": "2024-09-23 14:47:47.071991+08:00"
|
||||
},
|
||||
{
|
||||
"id": "cbeaaacc-67b6-4c09-92ac-c6f817b39d60",
|
||||
"num": "4HMH",
|
||||
"name": "试剂3",
|
||||
"quantity": 1,
|
||||
"action": 5,
|
||||
"typetask": 3,
|
||||
"created_at": "2024-09-23 14:47:47.079950+08:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
{
|
||||
"code": 200,
|
||||
"desc": "成功",
|
||||
"data": {
|
||||
"code": 200,
|
||||
"desc": "成功",
|
||||
"data": {
|
||||
"id": "2d143249-8ac9-4420-a389-50ca3f9a3838",
|
||||
"num": "7VI6",
|
||||
"orderid": "YD43fDD",
|
||||
"sequence": 0,
|
||||
"ordertime": "2024-08-28 00:00:00+08:00",
|
||||
"agvid": "001",
|
||||
"itinerary": [
|
||||
"01-0112"
|
||||
],
|
||||
"cmd": [
|
||||
{
|
||||
"01-0112-1-1": {
|
||||
"orderid": "YD43fDD",
|
||||
"name": "试剂12",
|
||||
"typetask": 1,
|
||||
"action": 3,
|
||||
"quantity": 1,
|
||||
"height": 156,
|
||||
"bottle": 60,
|
||||
"cap": 30,
|
||||
"coordinates": "01-0112-3-2",
|
||||
"traynum": "1W04"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0112-1-2": {
|
||||
"orderid": "YD43fDD",
|
||||
"name": "试剂13",
|
||||
"typetask": 1,
|
||||
"action": 3,
|
||||
"quantity": 1,
|
||||
"height": 156,
|
||||
"bottle": 60,
|
||||
"cap": 30,
|
||||
"coordinates": "01-0112-3-3",
|
||||
"traynum": "1P07"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0112-1-3": {
|
||||
"orderid": "YD43fDD",
|
||||
"name": "试剂11",
|
||||
"typetask": 1,
|
||||
"action": 3,
|
||||
"quantity": 1,
|
||||
"height": 156,
|
||||
"bottle": 60,
|
||||
"cap": 30,
|
||||
"coordinates": "01-0112-3-1",
|
||||
"traynum": "1E01"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0112-1-4": {
|
||||
"orderid": "YD43fDD",
|
||||
"name": "试剂15",
|
||||
"typetask": 1,
|
||||
"action": 3,
|
||||
"quantity": 1,
|
||||
"height": 156,
|
||||
"bottle": 60,
|
||||
"cap": 30,
|
||||
"coordinates": "01-0112-3-4",
|
||||
"traynum": "1Y09"
|
||||
}
|
||||
}
|
||||
],
|
||||
"last": "01-0112",
|
||||
"loada": 4,
|
||||
"loadb": 0,
|
||||
"loadc": 0,
|
||||
"loadd": 0,
|
||||
"loade": 0,
|
||||
"is_canceled": false,
|
||||
"cancel_time": "None",
|
||||
"is_processing": false,
|
||||
"is_failed": false,
|
||||
"is_done": false,
|
||||
"is_valid": true,
|
||||
"updated_at": "2024-09-23 15:05:43.787772+08:00",
|
||||
"created_at": "2024-09-23 15:05:43.746879+08:00",
|
||||
"owner": {
|
||||
"id": "4f7cbe2e-dedf-4a6c-ae19-fb48820dc5fc",
|
||||
"username": "2346",
|
||||
"name": "2346",
|
||||
"is_locked": true,
|
||||
"phone": "7459344674",
|
||||
"email": "lsr@126.com"
|
||||
},
|
||||
"subtasks": [
|
||||
{
|
||||
"id": "b62740c6-2744-49ed-8590-9505f8f030a1",
|
||||
"num": "3NPV",
|
||||
"name": "试剂12",
|
||||
"quantity": 1,
|
||||
"action": 3,
|
||||
"typetask": 1,
|
||||
"created_at": "2024-09-23 15:05:43.702814+08:00"
|
||||
},
|
||||
{
|
||||
"id": "4e6a89a8-1313-4157-81a5-b2c3a1cf67dd",
|
||||
"num": "9UZ8",
|
||||
"name": "试剂13",
|
||||
"quantity": 1,
|
||||
"action": 3,
|
||||
"typetask": 1,
|
||||
"created_at": "2024-09-23 15:05:43.716483+08:00"
|
||||
},
|
||||
{
|
||||
"id": "7f5c3582-24f3-44d2-a97b-25b290ba45d6",
|
||||
"num": "1TLD",
|
||||
"name": "试剂11",
|
||||
"quantity": 1,
|
||||
"action": 3,
|
||||
"typetask": 1,
|
||||
"created_at": "2024-09-23 15:05:43.688163+08:00"
|
||||
},
|
||||
{
|
||||
"id": "2bd62d41-3ba6-4a7b-bfa7-932f007adc10",
|
||||
"num": "SHS9",
|
||||
"name": "试剂15",
|
||||
"quantity": 1,
|
||||
"action": 3,
|
||||
"typetask": 1,
|
||||
"created_at": "2024-09-23 15:05:43.731238+08:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
[
|
||||
{
|
||||
"Return": {
|
||||
"cap": 30,
|
||||
"name": "试剂6",
|
||||
"action": 1,
|
||||
"bottle": 60,
|
||||
"height": 156,
|
||||
"orderid": "tr45f6r",
|
||||
"traynum": "1T01",
|
||||
"quantity": 1,
|
||||
"typetask": 1,
|
||||
"coordinates": "01-0111-2-6"
|
||||
}
|
||||
}
|
||||
]
|
@ -0,0 +1,91 @@
|
||||
{
|
||||
"code": 200,
|
||||
"desc": "成功",
|
||||
"data": {
|
||||
"code": 200,
|
||||
"desc": "成功",
|
||||
"data": {
|
||||
"id": "a02e80bd-799e-46b8-b7a8-b9699095858a",
|
||||
"num": "CWM0",
|
||||
"orderid": "tr43frr",
|
||||
"sequence": 0,
|
||||
"ordertime": "2024-08-23 00:00:00+08:00",
|
||||
"agvid": "001",
|
||||
"itinerary": [
|
||||
"01-0111"
|
||||
],
|
||||
"cmd": [
|
||||
{
|
||||
"01-0067-2-3": {
|
||||
"orderid": "tr43frr",
|
||||
"name": "大白瓶",
|
||||
"typetask": 3,
|
||||
"action": 5,
|
||||
"quantity": 1,
|
||||
"height": 180,
|
||||
"bottle": 60,
|
||||
"cap": 40,
|
||||
"coordinates": "01-0111-3-2",
|
||||
"traynum": "1X01"
|
||||
}
|
||||
},
|
||||
{
|
||||
"01-0067-2-4": {
|
||||
"orderid": "tr43frr",
|
||||
"name": "无水亚硫酸钠",
|
||||
"typetask": 3,
|
||||
"action": 5,
|
||||
"quantity": 1,
|
||||
"height": 150,
|
||||
"bottle": 60,
|
||||
"cap": 70,
|
||||
"coordinates": "01-0111-3-5",
|
||||
"traynum": "1X02"
|
||||
}
|
||||
}
|
||||
],
|
||||
"last": "01-0111",
|
||||
"loada": 0,
|
||||
"loadb": 2,
|
||||
"loadc": 0,
|
||||
"loadd": 0,
|
||||
"loade": 0,
|
||||
"is_canceled": false,
|
||||
"cancel_time": "None",
|
||||
"is_processing": false,
|
||||
"is_failed": false,
|
||||
"is_done": false,
|
||||
"is_valid": true,
|
||||
"updated_at": "2024-09-29 16:09:45.812042+08:00",
|
||||
"created_at": "2024-09-29 16:09:45.789580+08:00",
|
||||
"owner": {
|
||||
"id": "4f7cbe2e-dedf-4a6c-ae19-fb48820dc5fc",
|
||||
"username": "2346",
|
||||
"name": "2346",
|
||||
"is_locked": true,
|
||||
"phone": "7459344674",
|
||||
"email": "lsr@126.com"
|
||||
},
|
||||
"subtasks": [
|
||||
{
|
||||
"id": "a401e3df-6a8c-489d-a4f9-43959c848ab9",
|
||||
"num": "KQF0",
|
||||
"name": "大白瓶",
|
||||
"quantity": 1,
|
||||
"action": 5,
|
||||
"typetask": 3,
|
||||
"created_at": "2024-09-29 16:09:45.748586+08:00"
|
||||
},
|
||||
{
|
||||
"id": "f5d4a96e-4dff-4b7f-8331-8c265786be28",
|
||||
"num": "AU3W",
|
||||
"name": "无水亚硫酸钠",
|
||||
"quantity": 1,
|
||||
"action": 5,
|
||||
"typetask": 3,
|
||||
"created_at": "2024-09-29 16:09:45.770106+08:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
from fastapi import APIRouter
|
||||
from .views import warehouse_router
|
||||
|
||||
router = APIRouter(prefix='/api/scheduler')
|
||||
|
||||
|
||||
router.include_router(warehouse_router, tags=["AGV小车托盘管理模块"])
|
||||
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "agv"
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "agv",
|
||||
"memo": {"ver": "V1.0"},
|
||||
"vacancies": [
|
||||
{"number": "Left", "traynum": "", "memo": [], "is_empty": ""},
|
||||
{"number": "Right", "traynum": "", "memo": [], "is_empty": ""}
|
||||
]
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
from fastapi import APIRouter
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional, List, Any
|
||||
from starlette.requests import Request
|
||||
from tortoise.queryset import QuerySet, Prefetch
|
||||
import traceback
|
||||
from models.warehouse import (
|
||||
Vacancy,
|
||||
Connection,
|
||||
)
|
||||
|
||||
from helper import respond_to
|
||||
from conf import setting
|
||||
from tortoise.transactions import in_transaction
|
||||
|
||||
warehouse_router = APIRouter(prefix='/warehouse')
|
||||
|
||||
|
||||
class VacancyM(BaseModel):
|
||||
number: str
|
||||
traynum: Optional[str] = None
|
||||
memo: Optional[Any] = None
|
||||
is_empty: Optional[str] = "false"
|
||||
orderids: Optional[List[str]] = []
|
||||
|
||||
class ConnectionM(BaseModel):
|
||||
name: str
|
||||
vacancies: list[VacancyM]
|
||||
memo: Optional[Any] = None
|
||||
|
||||
class SchelveM(BaseModel):
|
||||
name: str
|
||||
vacancies: list[VacancyM]
|
||||
memo: Optional[Any] = None
|
||||
|
||||
class WarehouseM(BaseModel):
|
||||
name: str
|
||||
schelves: list[SchelveM]
|
||||
memo: Optional[Any] = None
|
||||
|
||||
class WarehouseMClear(BaseModel):
|
||||
name: str
|
||||
schelvenames: Optional[list[str]] = []
|
||||
|
||||
class ConnectionM(BaseModel):
|
||||
name: str
|
||||
vacancies: list[VacancyM]
|
||||
memo: Optional[Any] = None
|
||||
|
||||
class ConnectionMClear(BaseModel):
|
||||
name: str
|
||||
|
||||
@warehouse_router.get("/")
|
||||
def read_root():
|
||||
return {"Hello": "World"}
|
||||
|
||||
|
||||
|
||||
@warehouse_router.post('/addcon', summary='仓库添加AGV库存')
|
||||
async def createcon(request: Request, connectionM: ConnectionM):
|
||||
|
||||
# print("orderm: ", orderm)
|
||||
print("connectionM: ", connectionM.name, connectionM.memo)
|
||||
|
||||
for vacancy in connectionM.vacancies:
|
||||
print("vacancy ", vacancy.number)
|
||||
|
||||
async with in_transaction() as conn:
|
||||
try:
|
||||
connection = None
|
||||
qs1 = await Connection.filter(name = connectionM.name, is_active = True, is_valid = True)
|
||||
print("qs1: ", qs1, connectionM.name, connectionM.memo)
|
||||
if len(qs1) > 0:
|
||||
connection = qs1[0]
|
||||
else:
|
||||
connection = await Connection.create(
|
||||
name = connectionM.name,
|
||||
memo = connectionM.memo,
|
||||
connection=conn
|
||||
)
|
||||
|
||||
for vacancy in connectionM.vacancies:
|
||||
vacancyObj = None
|
||||
qs3 = await Vacancy.filter(number = vacancy.number, is_active = True, is_valid = True)
|
||||
if len(qs3) > 0:
|
||||
vacancyObj = qs3[0]
|
||||
else:
|
||||
vacancyObj = await Vacancy.create(
|
||||
number = vacancy.number,
|
||||
traynum = vacancy.traynum,
|
||||
memo = vacancy.memo,
|
||||
is_empty = True if "true" == vacancy.is_empty else False,
|
||||
is_connect = True,
|
||||
connection=conn
|
||||
)
|
||||
|
||||
#add to connection
|
||||
await connection.vacancies.add(vacancyObj)
|
||||
|
||||
except Exception as e:
|
||||
# printing stack trace
|
||||
traceback.print_exc()
|
||||
msg = "Something wrong when creating connection: {}".format(e)
|
||||
print(msg)
|
||||
return respond_to(code=404, desc="失败", data={"state": msg})
|
||||
|
||||
return respond_to(data={"state": "success"})
|
||||
|
||||
@warehouse_router.post('/clearcon', summary='仓库清空AGV库存')
|
||||
async def clearcon(request: Request, connectionMClear: ConnectionMClear):
|
||||
|
||||
# print("orderm: ", orderm)
|
||||
print("connectionMClear: ", connectionMClear.name)
|
||||
|
||||
try:
|
||||
connection = None
|
||||
qs1 = await Connection.filter(name = connectionMClear.name, is_active = True, is_valid = True)
|
||||
print("qs1: ", qs1)
|
||||
if len(qs1) > 0:
|
||||
connection = qs1[0]
|
||||
else:
|
||||
raise Exception("Cannot find connection name {}".format(connectionMClear.name))
|
||||
|
||||
await connection.fetch_related("vacancies")
|
||||
for vacancy in connection.vacancies:
|
||||
vacancy.is_valid = False
|
||||
vacancy.is_active = False
|
||||
await vacancy.save()
|
||||
|
||||
except Exception as e:
|
||||
# printing stack trace
|
||||
traceback.print_exc()
|
||||
msg = "Something wrong when creating connection: {}".format(e)
|
||||
print(msg)
|
||||
return respond_to(code=404, desc="失败", data={"state": msg})
|
||||
|
||||
return respond_to(data={"state": "success"})
|
||||
|
||||
|
||||
@warehouse_router.get('/listcon', summary="列出所有AGV库存")
|
||||
async def index(request: Request, page_no: int = 1, page_size: int = 20):
|
||||
"""
|
||||
列出所有AGV库存
|
||||
:param page_no: 1
|
||||
:param page_size: 20
|
||||
:return:
|
||||
"""
|
||||
offset = (page_no - 1) * page_size
|
||||
|
||||
query = QuerySet(Connection).filter(is_active=True).prefetch_related(
|
||||
Prefetch('vacancies', queryset=Vacancy.filter(is_active = True))
|
||||
)
|
||||
|
||||
count = await query.count()
|
||||
connections = await query.limit(page_size).offset(offset)
|
||||
|
||||
resData = []
|
||||
for connection in connections:
|
||||
vacancies = await connection.vacancies.filter(is_active = True)
|
||||
|
||||
vacancyList = []
|
||||
for vacancy in vacancies:
|
||||
holes = await vacancy.holes.filter(is_active = True)
|
||||
vacancyj = vacancy.as_json()
|
||||
vacancyj["holes"] = holes
|
||||
vacancyList.append(vacancyj)
|
||||
|
||||
connectionj = connection.as_json()
|
||||
# connectionj["vacancies"] = vacancies
|
||||
connectionj["vacancies"] = vacancyList
|
||||
resData.append(connectionj)
|
||||
|
||||
return respond_to(code=200, data=dict(count=count, data=resData))
|
||||
|
@ -1,123 +1 @@
|
||||
.INFO 12272:28072 2024-09-06 16:04:38,142 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 16:04:38,144 - INFO - Application startup complete.
|
||||
2024-09-06 16:07:15,590 - ERROR - Exception in ASGI application
|
||||
Traceback (most recent call last):
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\base.py", line 78, in call_next
|
||||
message = await recv_stream.receive()
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\anyio\streams\memory.py", line 94, in receive
|
||||
return self.receive_nowait()
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\anyio\streams\memory.py", line 87, in receive_nowait
|
||||
raise EndOfStream
|
||||
anyio.EndOfStream
|
||||
|
||||
During handling of the above exception, another exception occurred:
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 435, in run_asgi
|
||||
result = await app( # type: ignore[func-returns-value]
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in __call__
|
||||
return await self.app(scope, receive, send)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\applications.py", line 276, in __call__
|
||||
await super().__call__(scope, receive, send)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\applications.py", line 122, in __call__
|
||||
await self.middleware_stack(scope, receive, send)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\errors.py", line 184, in __call__
|
||||
raise exc
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\errors.py", line 162, in __call__
|
||||
await self.app(scope, receive, _send)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
|
||||
await self.app(scope, receive, send)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\base.py", line 108, in __call__
|
||||
response = await self.dispatch_func(request, call_next)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "D:\AutoTaskSchedule\simAgv\main.py", line 54, in process_time_header
|
||||
response = await next(request)
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
|
||||
raise app_exc
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
|
||||
await self.app(scope, receive_or_disconnect, send_no_error)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
|
||||
raise exc
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
|
||||
await self.app(scope, receive, sender)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
|
||||
raise e
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
|
||||
await self.app(scope, receive, send)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\routing.py", line 718, in __call__
|
||||
await route.handle(scope, receive, send)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\routing.py", line 276, in handle
|
||||
await self.app(scope, receive, send)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\starlette\routing.py", line 66, in app
|
||||
response = await func(request)
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\routing.py", line 237, in app
|
||||
raw_response = await run_endpoint_function(
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\fastapi\routing.py", line 163, in run_endpoint_function
|
||||
return await dependant.call(**values)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "D:\AutoTaskSchedule\simAgv\logic\agv\views.py", line 35, in index
|
||||
query = QuerySet(Agv).filter(is_valid=True, is_active=True)
|
||||
^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\tortoise\queryset.py", line 299, in __init__
|
||||
super().__init__(model)
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\tortoise\queryset.py", line 96, in __init__
|
||||
self.capabilities: Capabilities = model._meta.db.capabilities
|
||||
^^^^^^^^^^^^^^
|
||||
File "C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\tortoise\models.py", line 285, in db
|
||||
raise ConfigurationError(
|
||||
tortoise.exceptions.ConfigurationError: default_connection for the model <class 'models.agv.Agv'> cannot be None
|
||||
2024-09-06 16:08:17,538 - INFO - Shutting down
|
||||
2024-09-06 16:08:17,647 - INFO - Waiting for application shutdown.
|
||||
2024-09-06 16:08:17,649 - INFO - Application shutdown complete.
|
||||
2024-09-06 16:08:17,650 - INFO - Finished server process [12272]
|
||||
INFO 11504:26992 2024-09-06 16:19:14,235 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 16:19:14,237 - INFO - Application startup complete.
|
||||
2024-09-06 16:28:08,549 - INFO - Shutting down
|
||||
2024-09-06 16:28:08,658 - INFO - Waiting for application shutdown.
|
||||
2024-09-06 16:28:08,661 - INFO - Application shutdown complete.
|
||||
2024-09-06 16:28:08,662 - INFO - Finished server process [11504]
|
||||
INFO 14408:36888 2024-09-06 16:28:09,897 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 16:28:09,899 - INFO - Application startup complete.
|
||||
2024-09-06 16:28:11,095 - INFO - Shutting down
|
||||
2024-09-06 16:28:11,205 - INFO - Waiting for application shutdown.
|
||||
2024-09-06 16:28:11,207 - INFO - Application shutdown complete.
|
||||
2024-09-06 16:28:11,208 - INFO - Finished server process [14408]
|
||||
INFO 33012:30064 2024-09-06 17:33:05,949 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 17:33:05,951 - INFO - Application startup complete.
|
||||
2024-09-06 17:33:15,443 - INFO - Shutting down
|
||||
2024-09-06 17:33:15,553 - INFO - Waiting for application shutdown.
|
||||
2024-09-06 17:33:15,554 - INFO - Application shutdown complete.
|
||||
2024-09-06 17:33:15,555 - INFO - Finished server process [33012]
|
||||
INFO 33740:5880 2024-09-06 17:33:22,981 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 17:33:22,983 - INFO - Application startup complete.
|
||||
2024-09-06 17:33:26,258 - INFO - Shutting down
|
||||
2024-09-06 17:33:26,367 - INFO - Waiting for application shutdown.
|
||||
2024-09-06 17:33:26,367 - INFO - Application shutdown complete.
|
||||
2024-09-06 17:33:26,367 - INFO - Finished server process [33740]
|
||||
INFO 35040:17000 2024-09-06 17:34:07,447 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 17:34:07,449 - INFO - Application startup complete.
|
||||
2024-09-06 17:49:24,793 - INFO - Shutting down
|
||||
2024-09-06 17:49:24,901 - INFO - Waiting for application shutdown.
|
||||
2024-09-06 17:49:24,905 - INFO - Application shutdown complete.
|
||||
2024-09-06 17:49:24,906 - INFO - Finished server process [35040]
|
||||
INFO 40716:17136 2024-09-06 17:49:25,709 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 17:49:25,710 - INFO - Application startup complete.
|
||||
2024-09-06 17:52:02,164 - INFO - Shutting down
|
||||
2024-09-06 17:52:02,273 - INFO - Waiting for application shutdown.
|
||||
2024-09-06 17:52:02,274 - INFO - Application shutdown complete.
|
||||
2024-09-06 17:52:02,275 - INFO - Finished server process [40716]
|
||||
INFO 34940:9244 2024-09-06 17:52:03,508 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 17:52:03,510 - INFO - Application startup complete.
|
||||
2024-09-06 17:59:04,023 - INFO - Shutting down
|
||||
2024-09-06 17:59:04,130 - INFO - Waiting for application shutdown.
|
||||
2024-09-06 17:59:04,132 - INFO - Application shutdown complete.
|
||||
2024-09-06 17:59:04,132 - INFO - Finished server process [34940]
|
||||
INFO 36040:23864 2024-09-06 17:59:05,373 agvtasks.py:273 - SERVER - 准备启动AGV小车任务派发定时任务, 间隔时间: 12
|
||||
2024-09-06 17:59:05,375 - INFO - Application startup complete.
|
||||
2024-12-26 08:52:15,322 - INFO - Application startup complete.
|
||||
|
@ -0,0 +1 @@
|
||||
2024-11-15 09:09:53,940 - INFO - Application startup complete.
|
@ -0,0 +1 @@
|
||||
2024-11-16 08:43:13,410 - INFO - Application startup complete.
|
@ -0,0 +1 @@
|
||||
2024-11-17 15:41:26,854 - INFO - Application startup complete.
|
@ -0,0 +1,2 @@
|
||||
2024-11-20 09:28:43,861 - INFO - Application startup complete.
|
||||
2024-11-20 16:36:16,191 - INFO - Application startup complete.
|
@ -0,0 +1,2 @@
|
||||
2024-11-21 10:00:32,775 - INFO - Application startup complete.
|
||||
2024-11-21 13:14:11,180 - INFO - Application startup complete.
|
@ -0,0 +1 @@
|
||||
2024-11-22 08:53:11,793 - INFO - Application startup complete.
|
@ -0,0 +1,5 @@
|
||||
2024-11-23 09:13:25,067 - INFO - Application startup complete.
|
||||
2024-11-23 17:01:34,858 - INFO - Shutting down
|
||||
2024-11-23 17:01:34,994 - INFO - Waiting for application shutdown.
|
||||
2024-11-23 17:01:35,004 - INFO - Application shutdown complete.
|
||||
2024-11-23 17:01:35,004 - INFO - Finished server process [3524]
|
@ -0,0 +1 @@
|
||||
2024-11-26 10:10:18,833 - INFO - Application startup complete.
|
@ -0,0 +1 @@
|
||||
2024-11-28 14:27:37,909 - INFO - Application startup complete.
|
@ -0,0 +1,10 @@
|
||||
2024-11-29 08:39:39,942 - INFO - Application startup complete.
|
||||
2024-11-29 09:38:23,604 - INFO - Shutting down
|
||||
2024-11-29 09:38:23,733 - INFO - Waiting for application shutdown.
|
||||
2024-11-29 09:38:23,744 - INFO - Application shutdown complete.
|
||||
2024-11-29 09:38:23,744 - INFO - Finished server process [20000]
|
||||
2024-11-29 09:38:25,963 - INFO - Application startup complete.
|
||||
2024-11-29 17:51:16,100 - INFO - Shutting down
|
||||
2024-11-29 17:51:16,223 - INFO - Waiting for application shutdown.
|
||||
2024-11-29 17:51:16,237 - INFO - Application shutdown complete.
|
||||
2024-11-29 17:51:16,237 - INFO - Finished server process [25204]
|
@ -0,0 +1 @@
|
||||
2024-12-02 08:32:04,715 - INFO - Application startup complete.
|
@ -0,0 +1,2 @@
|
||||
2024-12-03 08:31:20,338 - INFO - Application startup complete.
|
||||
2024-12-03 13:49:23,403 - INFO - Application startup complete.
|
@ -0,0 +1,10 @@
|
||||
2024-12-04 08:30:17,171 - INFO - Application startup complete.
|
||||
2024-12-04 17:11:22,790 - INFO - Application startup complete.
|
||||
2024-12-04 17:13:27,426 - INFO - Shutting down
|
||||
2024-12-04 17:13:27,527 - INFO - Waiting for application shutdown.
|
||||
2024-12-04 17:13:27,528 - INFO - Application shutdown complete.
|
||||
2024-12-04 17:13:27,529 - INFO - Finished server process [12380]
|
||||
2024-12-04 17:13:41,651 - INFO - Application startup complete.
|
||||
2024-12-04 17:19:24,014 - INFO - Application startup complete.
|
||||
2024-12-04 17:21:40,861 - INFO - Application startup complete.
|
||||
2024-12-04 17:22:11,142 - INFO - Application startup complete.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue