12/25/2020

PI : Motion Trick GPIO

Motion Trick GPIO By Python

ถ้า Error
root@raspberrypi:/home/pi# python3 SCI_Notify.py
Traceback (most recent call last):
File "SCI_Notify.py", line 10, in <module>
import RPi.GPIO as GPIO
ModuleNotFoundError: No module named 'RPi'[/quote]

ต้องลง Program เพิ่ม

  1. sudo apt-get -y install python3-rpi.gpio

 

เพิ่มเติมสั่ง Motion ให้สั่ง GPIO ไม่ได้ต้อง
Add user motion เข้า GPIO ก่อน

  1. sudo adduser motion gpio

 

12/15/2020

Axapta : Axapta End คำสั่งผลิตไม่ได้ เนื่องจากมี Reports ติดลบ

 Axapta : Axapta End คำสั่งผลิตไม่ได้ เนื่องจากมี Reports ติดลบ

คำสั่งผลิต Reports ติดลบ แล้วคำสั่งที่จะเอา Item จาก PD ที่ Reports ติดลบ ไปใช้งาน Upcost ไม่ได้ Error

Up Costing PD20-026941:465027353015 Error


Production - Costing
Calculating BOM comsumption
Financial item picking
...
Item consumption for .. cannot be updated, as the cost price is known only for 0.00 instock.
Update has been canceled.


เกิดจาก PD20-018752:061093653220 มีการ Post Reports ติดลบ ทำให้ยอดที่ Reports ตามมาทีหลังไม่เกิดมูลค่าและนำไปใช้งานในคำสั่งผลิตอื่น ไม่ได้







วิธีแก้ คือ ต้องลบ Transaction ที่เกิดขึ้นตอน +10 และ -10 ออกให้หมด ให้เลือกเฉพาะ 4 ตัวที่ Reports มาทีหลังเพราะมีการเอาไป Post Packing list แล้วที่ PD20-026941

1. แก้ข้อมูล Table : InventTrans ลอกข้อมูลให้เหมือนกับตัว +10 ที่ทำสำเร็จ ยกเว้นราคา กับ QTY
เช่น Field : StatusIssue, CostAmountPost, CurrencyCode, StatusReceipt, InvoicerTurned,Direction


2. ลบข้อมูล IniventTrans ที่ +10 กับ -10 ออก
3. Run Job recalcInventSum


4. ลบข้อมูล Reports PD ที่ผิดออก ให้เหลือแต่ตัวที่ถูกต้อง
ProdJournalProd และ ProdJournalTable และ ProdTableJour
5. Update คำสั่งผลิต PD20-026941 ที่ Error
6. ดู Onhand เรียกรายงาน Inventory และ Stockcard ดูความถูกต้อง






12/10/2020

PI : Python On Delay 10 Seconds

PI : Python On Delay 10 Seconds
การต่อ



เมื่อมีการทำงาน Python จะเปิด Delay และค้างไว้ 10 วิ และสั่ง Trick GPIO ขาที่ต่อ
Code Python
  1. import RPi.GPIO as GPIO
  2. import time
  3.  
  4. stop_time = time.time() + 10
  5.  
  6. GPIO.setmode(GPIO.BOARD)
  7. GPIO.setup(10,GPIO.OUT)
  8.  
  9. try:
  10.     while time.time() < stop_time:
  11.        GPIO.output(10,1)
  12.        time.sleep(0.0015)
  13.        GPIO.output(10,0)
  14.        time.sleep(0.01)
  15.  
  16. except KeyboardInterrupt:
  17.     pass
  18.  
  19. print"Stopping Auto-Feeder"
  20. GPIO.cleanup()

PI : PI Motion Monitor HC-SR501 PIR จับการเคลื่อนไหว และแจ้งเตือน

 PI : PI Motion Monitor HC-SR501 PIR จับการเคลื่อนไหว และแจ้งเตือน
การต่อ


เมื่อมีการเคลื่อนไหว ผ่าน หน้า Sensor ก็จะมีแจ้งเตือน ไฟก็จะติด
Code Python
  1. #!/usr/bin/python
  2.  
  3. import RPi.GPIO as GPIO
  4. import time
  5.  
  6. GPIO.setmode(GPIO.BOARD)            #Set GPIO to pin numbering
  7. pir = 8                             #Assign pin 8 to PIR
  8. led = 10                            #Assign pin 10 to LED
  9. GPIO.setup(pir, GPIO.IN)            #Setup GPIO pin PIR as input
  10. GPIO.setup(led, GPIO.OUT)           #Setup GPIO pin for LED as output
  11. print ("Sensor initializing . . .")
  12. time.sleep(2)                       #Give sensor time to startup
  13. print ("Active")
  14. print ("Press Ctrl+c to end program")
  15.  
  16. try:
  17.   while True:
  18.    if GPIO.input(pir) == True:      #If PIR pin goes high, motion is detected
  19.       print ("Motion Detected!")
  20.       GPIO.output(led, True)        #Turn on LED
  21.       time.sleep(4)                 #Keep LED on for 4 seconds
  22.    GPIO.output(led, False)          #Turn off LED
  23.    time.sleep(0.1)
  24.  
  25. except KeyboardInterrupt:           #Ctrl+c
  26.   pass                              #Do nothing, continue to finally
  27.  
  28. finally:
  29.   GPIO.output(led, False)           #Turn off LED in case left on
  30.   GPIO.cleanup()                    #reset all GPIO
  31.   print ("Program ended")
  32.  

12/07/2020

Axapta : Error Transaction is already marked for settlement

 Error Transaction is already marked for settlement.


ใน Open Transaction Editing เกิดขึ้นได้ทั้งฝั่ง Vendor และ Customer
เกิดจากมีการไปกด Mark ที่รายการนั้น
1. เข้าไปหาเล่มที่จะปลด Mark ออก เข้าไปที่
Inquiry --> Specifications
2. เลือก View ที่ต้องการดู เป็นเช่น Sales Order แล้วกด Open Journal Form

3. กด Functions --> Open Transaction Editing

4. ตอบ No
5. กดจะมีรายการ Mark ไว้ ให้ติ๊กออก

6. กลับไปที่ Open Transaction Editing ของ Customer Is Mark จะหายไป ก็จะสามารถกด Mark และ Update ออกได้




11/07/2020

SQL : SQL Server Enterprise Manager นำเข้าข้อมูลจากการ Query

 SQL : SQL Server Enterprise Manager นำเข้าข้อมูลจากการ Query
โดยการ Query เอาเฉพาะข้อมูลส่วนที่ต่างกัน หรือส่วนที่ไม่มีในอีก Table 1
1. นำ Table ที่ต้องการมาไว้ที่ Database เดียวกัน ด้วยการ copy table และใส่ชื่อต่อท้าย


2. เลือก Table ที่ต้องการ Export
เลือก Source Database
เลือก Destination Database
3. เลือก Use a query to specify the data to transfer.

4. เขียนคำสั่งสำหรับ Query (สามารถไปลองใน SQL ก่อนเพื่อดูความถูกต้องของข้อมูลแล้วค่อย copy มาใส่ก็ได้)
ตัวอย่างคือ เอาข้อมูลที่ไม่มีใน Table2 ไปเทียบกับข้อมูลใน Table1 ใช้ NOT EXISTS

5. เลือก Table destination สามารถกด Preview เพื่อดูข้อมูล หรือกด Transform เพื่อดู File ได้
6. กด Next
7. กด Finish ดูรายระเอียดว่าส่งไปถูกที่หรือไม่
8. ส่งข้อมูลสำเร็จ